diff --git a/README.md b/README.md index e4f959d..704d4de 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ Also available in Play Store - :white_check_mark: Kotlin - :white_check_mark: Live data +- :white_check_mark: DataBinding - :white_check_mark: Navigation +- :white_check_mark: SafeArgs - :white_check_mark: ViewModel - :white_check_mark: Rest with retrofit - :white_check_mark: Offline Persistence with Room diff --git a/app/build.gradle b/app/build.gradle index 1622d88..57ed5ed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + + dataBinding { + enabled = true + } } dependencies { diff --git a/app/src/main/java/dev/marcosfarias/pokedex/adapter/MenuAdapter.kt b/app/src/main/java/dev/marcosfarias/pokedex/adapter/MenuAdapter.kt index 5da3586..8568ade 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/adapter/MenuAdapter.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/adapter/MenuAdapter.kt @@ -32,7 +32,6 @@ class MenuAdapter( itemView.setOnClickListener { it.findNavController().navigate(R.id.action_navigation_home_to_navigation_pokedex) } - } } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/adapter/PokemonAdapter.kt b/app/src/main/java/dev/marcosfarias/pokedex/adapter/PokemonAdapter.kt index b4c93f9..e331d61 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/adapter/PokemonAdapter.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/adapter/PokemonAdapter.kt @@ -6,12 +6,12 @@ import android.graphics.PorterDuffColorFilter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.os.bundleOf import androidx.navigation.findNavController import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import dev.marcosfarias.pokedex.R import dev.marcosfarias.pokedex.model.Pokemon +import dev.marcosfarias.pokedex.ui.pokedex.PokedexFragmentDirections import dev.marcosfarias.pokedex.utils.PokemonColorUtil import kotlinx.android.synthetic.main.item_pokemon.view.* @@ -26,7 +26,7 @@ class PokemonAdapter( itemView.textViewID.text = item.id val color = PokemonColorUtil(itemView.context).getPokemonColor(item.typeofpokemon) - itemView.relativeLayoutBackground.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP ) + itemView.relativeLayoutBackground.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) item.typeofpokemon?.elementAtOrNull(0).let { itemView.textViewType3.text = it @@ -55,8 +55,7 @@ class PokemonAdapter( .into(itemView.imageView) itemView.setOnClickListener { - var bundle = bundleOf("id" to item.id) - it.findNavController().navigate(R.id.action_navigation_pokedex_to_navigation_dashboard, bundle) + it.findNavController().navigate(PokedexFragmentDirections.actionNavigationPokedexToNavigationDashboard(item.id!!)) } } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/database/dao/PokemonDAO.kt b/app/src/main/java/dev/marcosfarias/pokedex/database/dao/PokemonDAO.kt index d849a6d..a1cef09 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/database/dao/PokemonDAO.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/database/dao/PokemonDAO.kt @@ -8,7 +8,7 @@ import dev.marcosfarias.pokedex.model.Pokemon interface PokemonDAO { @Query("SELECT * FROM pokemon WHERE id = :id") - fun getById(id: String?): LiveData?> + fun getById(id: String?): LiveData @Query("SELECT * FROM pokemon") fun all(): LiveData> diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt index 25a6711..f370965 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardFragment.kt @@ -6,91 +6,84 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.bumptech.glide.Glide import dev.marcosfarias.pokedex.R import dev.marcosfarias.pokedex.adapter.ViewPagerAdapter +import dev.marcosfarias.pokedex.databinding.FragmentDashboardBinding import dev.marcosfarias.pokedex.ui.dashboard.about.AboutFragment import dev.marcosfarias.pokedex.ui.dashboard.evolution.EvolutionFragment import dev.marcosfarias.pokedex.ui.dashboard.moves.MovesFragment import dev.marcosfarias.pokedex.ui.dashboard.stats.StatsFragment import dev.marcosfarias.pokedex.utils.PokemonColorUtil -import kotlinx.android.synthetic.main.fragment_dashboard.view.* class DashboardFragment : Fragment() { private lateinit var dashboardViewModel: DashboardViewModel + private lateinit var binding: FragmentDashboardBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val id = DashboardFragmentArgs.fromBundle(arguments!!).pokemonId + + dashboardViewModel = ViewModelProviders.of(this, DashboardViewModelFactory(id)).get(DashboardViewModel::class.java) + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_dashboard, container, false) + binding.vm = dashboardViewModel + binding.lifecycleOwner = viewLifecycleOwner + + dashboardViewModel.pokemon.observe(this, Observer { pokemon -> + val color = PokemonColorUtil(requireContext()).getPokemonColor(pokemon?.typeofpokemon) + val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) + + binding.appBar.background.colorFilter = colorFilter + binding.toolbarLayout.contentScrim?.colorFilter = colorFilter + activity?.window?.statusBarColor = color + + pokemon?.typeofpokemon?.elementAtOrNull(0).let { + binding.textViewType3.text = it + if (it == null) { + binding.textViewType3.visibility = View.GONE + } + } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { - dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) - - val root = inflater.inflate(R.layout.fragment_dashboard, container, false) - - arguments?.getString("id").let { - - dashboardViewModel.getPokemonById(it).observe(this, Observer { list -> - list?.get(0).let { pokemon -> - root.textViewID.text = pokemon?.id - root.textViewName.text = pokemon?.name - - val color = PokemonColorUtil(root.context).getPokemonColor(pokemon?.typeofpokemon) - root.app_bar.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP ) - root.toolbar_layout.contentScrim?.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP ) - activity?.window?.statusBarColor = PokemonColorUtil(root.context).getPokemonColor(pokemon?.typeofpokemon) - - pokemon?.typeofpokemon?.elementAtOrNull(0).let { - root.textViewType3.text = it - if (it == null) { - root.textViewType3.visibility = View.GONE - } - } - - pokemon?.typeofpokemon?.elementAtOrNull(1).let { - root.textViewType2.text = it - if (it == null) { - root.textViewType2.visibility = View.GONE - } - } - - pokemon?.typeofpokemon?.elementAtOrNull(2).let { - root.textViewType1.text = it - if (it == null) { - root.textViewType1.visibility = View.GONE - } - } - - Glide.with(root.context) - .load(pokemon?.imageurl) - .placeholder(android.R.color.transparent) - .into(root.imageView) - - val pager = root.viewPager - val tabs = root.tabs - - - val adapter = ViewPagerAdapter(fragmentManager!!) - adapter.addFragment(AboutFragment.newInstance(pokemon?.id), getString(R.string.dashboard_tab_1)) - adapter.addFragment(StatsFragment.newInstance(pokemon?.id), getString(R.string.dashboard_tab_2)) - adapter.addFragment(EvolutionFragment(), getString(R.string.dashboard_tab_3)) - adapter.addFragment(MovesFragment(), getString(R.string.dashboard_tab_4)) - - pager.adapter = adapter - - tabs.setupWithViewPager(pager) + pokemon?.typeofpokemon?.elementAtOrNull(1).let { + binding.textViewType2.text = it + if (it == null) { + binding.textViewType2.visibility = View.GONE } + } + pokemon?.typeofpokemon?.elementAtOrNull(2).let { + binding.textViewType1.text = it + if (it == null) { + binding.textViewType1.visibility = View.GONE + } + } - }) + Glide.with(requireContext()) + .load(pokemon?.imageurl) + .placeholder(android.R.color.transparent) + .into(binding.imageView) + val pager = binding.viewPager + val tabs = binding.tabs - } + pager.adapter = ViewPagerAdapter(fragmentManager!!).apply { + addFragment(AboutFragment.newInstance(id), getString(R.string.dashboard_tab_1)) + addFragment(StatsFragment.newInstance(id), getString(R.string.dashboard_tab_2)) + addFragment(EvolutionFragment(), getString(R.string.dashboard_tab_3)) + addFragment(MovesFragment(), getString(R.string.dashboard_tab_4)) + } + tabs.setupWithViewPager(pager) + }) - return root + return binding.root } - - - } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModel.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModel.kt index 1b665cd..bb24f04 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModel.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModel.kt @@ -1,22 +1,17 @@ package dev.marcosfarias.pokedex.ui.dashboard import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import dev.marcosfarias.pokedex.App import dev.marcosfarias.pokedex.database.dao.PokemonDAO import dev.marcosfarias.pokedex.model.Pokemon -import dev.marcosfarias.pokedex.repository.APIService -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -class DashboardViewModel : ViewModel() { +class DashboardViewModel(pokemonId: String) : ViewModel() { - private val pokemonDAO : PokemonDAO = App.database!!.pokemonDAO() + private val pokemonDAO: PokemonDAO = App.database!!.pokemonDAO() + var pokemon: LiveData - fun getPokemonById(id: String?): LiveData?> { - return pokemonDAO.getById(id) + init { + pokemon = pokemonDAO.getById(pokemonId) } - } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModelFactory.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModelFactory.kt new file mode 100644 index 0000000..b46eff3 --- /dev/null +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModelFactory.kt @@ -0,0 +1,14 @@ +package dev.marcosfarias.pokedex.ui.dashboard + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider + +class DashboardViewModelFactory(private val id: String) : ViewModelProvider.Factory { + override fun create(modelClass: Class): T { + if (modelClass.isAssignableFrom(DashboardViewModel::class.java)) { + return DashboardViewModel(id) as T + } + throw IllegalArgumentException("Unknown ViewModel class") + } + +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt index 654cfaf..fc157ab 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/about/AboutFragment.kt @@ -4,53 +4,35 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment -import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.databinding.FragmentAboutBinding import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel -import kotlinx.android.synthetic.main.fragment_about.view.* +import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModelFactory class AboutFragment : Fragment() { + private lateinit var dashboardViewModel: DashboardViewModel + private lateinit var binding: FragmentAboutBinding + companion object { @JvmStatic - fun newInstance(id: String?) = AboutFragment().apply { - arguments = Bundle().apply { - putString("id", id) - } + fun newInstance(id: String) = AboutFragment().apply { + arguments = AboutFragmentArgs.Builder(id).build().toBundle() } } - private lateinit var dashboardViewModel: DashboardViewModel - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) - - val root = inflater.inflate(R.layout.fragment_about, container, false) - arguments?.getString("id").let { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val id = AboutFragmentArgs.fromBundle(arguments!!).pokemonId + dashboardViewModel = ViewModelProviders.of(this, DashboardViewModelFactory(id)).get(DashboardViewModel::class.java) + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_about, container, false) - dashboardViewModel.getPokemonById(it).observe(this, Observer { list -> - list?.get(0).let { pokemon -> + binding.vm = dashboardViewModel + binding.lifecycleOwner = viewLifecycleOwner - root.textViewDescription.text = pokemon?.xdescription - root.textViewHeight.text = pokemon?.height - root.textViewWeight.text = pokemon?.weight - root.textViewEggCycle.text = pokemon?.cycles - root.textViewEggGroups.text = pokemon?.egg_groups - root.textViewBaseEXP.text = pokemon?.base_exp - } - }) - } - - - return root + return binding.root } - - } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt index 306d44a..24bce3b 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionFragment.kt @@ -5,23 +5,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProviders import dev.marcosfarias.pokedex.R -import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel class EvolutionFragment : Fragment() { - private lateinit var dashboardViewModel: DashboardViewModel - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { - dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) - - val root = inflater.inflate(R.layout.fragment_evolution, container, false) - - - return root - } - - - + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_evolution, container, false) } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt index ff38953..a593aa2 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt @@ -9,9 +9,5 @@ import dev.marcosfarias.pokedex.R class MovesFragment : Fragment() { - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { - val root = inflater.inflate(R.layout.fragment_moves, container, false) - return root - } - + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_moves, container, false) } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt index e81e10d..f1533ca 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/stats/StatsFragment.kt @@ -4,60 +4,34 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment -import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import dev.marcosfarias.pokedex.R +import dev.marcosfarias.pokedex.databinding.FragmentStatsBinding import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel -import kotlinx.android.synthetic.main.fragment_stats.view.* +import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModelFactory class StatsFragment : Fragment() { + private lateinit var dashboardViewModel: DashboardViewModel + private lateinit var binding: FragmentStatsBinding + companion object { @JvmStatic - fun newInstance(id: String?) = StatsFragment().apply { - arguments = Bundle().apply { - putString("id", id) - } + fun newInstance(id: String) = StatsFragment().apply { + arguments = StatsFragmentArgs.Builder(id).build().toBundle() } } - private lateinit var dashboardViewModel: DashboardViewModel - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { - dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java) - - val root = inflater.inflate(R.layout.fragment_stats, container, false) - - arguments?.getString("id").let { - - dashboardViewModel.getPokemonById(it).observe(this, Observer { list -> - list?.get(0).let { pokemon -> + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val id = StatsFragmentArgs.fromBundle(arguments!!).pokemonId + dashboardViewModel = ViewModelProviders.of(this, DashboardViewModelFactory(id)).get(DashboardViewModel::class.java) + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_stats, container, false) - root.textViewTypeDefenses.text = pokemon?.ydescription + binding.vm = dashboardViewModel + binding.lifecycleOwner = viewLifecycleOwner - root.textViewHP.text = pokemon?.hp.toString() - root.textViewAttack.text = pokemon?.attack.toString() - root.textViewDefense.text = pokemon?.defense.toString() - root.textViewSpAtk.text = pokemon?.special_attack.toString() - root.textViewSpDef.text = pokemon?.special_defense.toString() - root.textViewSpeed.text = pokemon?.speed.toString() - root.textViewTotal.text = pokemon?.total.toString() - - root.progressBarHP.progress = pokemon?.hp ?: 0 - root.progressBarAttack.progress = pokemon?.attack ?: 0 - root.progressBarDefense.progress = pokemon?.defense ?: 0 - root.progressBarSpAtk.progress = pokemon?.special_attack ?: 0 - root.progressBarSpDef.progress = pokemon?.special_defense ?: 0 - root.progressBarSpeed.progress = pokemon?.speed ?: 0 - root.progressBarTotal.progress = pokemon?.total ?: 0 - } - }) - } - - return root + return binding.root } - - - } \ No newline at end of file diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationFragment.kt index f2339ed..5684806 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationFragment.kt @@ -27,8 +27,7 @@ class GenerationFragment : BottomSheetDialogFragment() { recyclerView.layoutManager = layoutManager generationViewModel.getListGeneration().observe(this, Observer { - val pokemons : List = it - recyclerView.adapter = GenerationAdapter(pokemons, root.context) + recyclerView.adapter = GenerationAdapter(it, root.context) }) return root } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/home/HomeFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/home/HomeFragment.kt index c0f76a2..8b87439 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/home/HomeFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/home/HomeFragment.kt @@ -11,6 +11,7 @@ import androidx.lifecycle.ViewModelProviders import androidx.navigation.findNavController import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager import dev.marcosfarias.pokedex.App import dev.marcosfarias.pokedex.R import dev.marcosfarias.pokedex.adapter.MenuAdapter @@ -39,17 +40,15 @@ class HomeFragment : Fragment() { recyclerViewMenu.layoutManager = GridLayoutManager(context, 2) - recyclerViewNews.layoutManager = GridLayoutManager(context, 1) + recyclerViewNews.layoutManager = LinearLayoutManager(context) recyclerViewNews.addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL)) homeViewModel.getListMenu().observe(this, Observer { - val items: List = it - recyclerViewMenu.adapter = MenuAdapter(items, root.context) + recyclerViewMenu.adapter = MenuAdapter(it, root.context) }) homeViewModel.getListNews().observe(this, Observer { - val items: List = it - recyclerViewNews.adapter = NewsAdapter(items, root.context) + recyclerViewNews.adapter = NewsAdapter(it, root.context) }) return root } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/pokedex/PokedexViewModel.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/pokedex/PokedexViewModel.kt index c466349..7d87783 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/pokedex/PokedexViewModel.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/pokedex/PokedexViewModel.kt @@ -46,6 +46,5 @@ class PokedexViewModel : ViewModel() { return pokemonDAO.all() } - } diff --git a/app/src/main/java/dev/marcosfarias/pokedex/ui/search/SearchFragment.kt b/app/src/main/java/dev/marcosfarias/pokedex/ui/search/SearchFragment.kt index 529db97..c0496a1 100644 --- a/app/src/main/java/dev/marcosfarias/pokedex/ui/search/SearchFragment.kt +++ b/app/src/main/java/dev/marcosfarias/pokedex/ui/search/SearchFragment.kt @@ -9,11 +9,6 @@ import dev.marcosfarias.pokedex.R class SearchFragment : BottomSheetDialogFragment() { - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) : View? { - - val root = inflater.inflate(R.layout.fragment_search, container, false) - - return root - } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_search, container, false) } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index a467bc9..b166d0c 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -1,224 +1,241 @@ - - - + + + + + + + + android:layout_height="match_parent" + android:background="@color/backgroundLight" + android:fillViewport="true" + android:paddingStart="16dp" + android:paddingEnd="16dp"> - + android:orientation="vertical"> - + + android:layout_marginTop="8dp" + android:text="@{vm.pokemon.xdescription}" + android:textSize="16sp" + tools:text="@string/lorem_small" /> + + + android:layout_margin="16dp" + android:orientation="horizontal"> - + android:layout_weight="1" + android:orientation="vertical"> + - + + + + + + + + + + + + - + + + + + + - - + android:text="Gender" + android:textSize="16sp" /> - + - - + - + - - + + - + android:layout_marginTop="8dp" + android:orientation="horizontal"> - + - - + + - - - - + android:textSize="18sp" + android:textStyle="bold" /> - + android:layout_marginTop="8dp" + android:adjustViewBounds="true" + android:src="@drawable/map" /> + android:textSize="18sp" + android:textStyle="bold" /> - - - - - - - - - - - - + android:layout_marginTop="8dp" + android:layout_marginBottom="32dp" + android:orientation="horizontal"> + - + + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index 39c66be..b0e4094 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -1,186 +1,197 @@ - + xmlns:tools="http://schemas.android.com/tools"> - + + + + - - - - - + + + - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + android:layout_height="match_parent" + android:fillViewport="true" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_stats.xml b/app/src/main/res/layout/fragment_stats.xml index be45e50..c4a2a12 100644 --- a/app/src/main/res/layout/fragment_stats.xml +++ b/app/src/main/res/layout/fragment_stats.xml @@ -1,297 +1,321 @@ - - - + - + - + + - - - - - + + android:orientation="vertical"> - - - + + + + + + + + + + - - - - - - - - + + + + + + + + + + - - + + + + + + + + + + - - - - - - - - + + + + + + + + + + - - + + + + + + + + + + - - - - - - - - + + + + + + + + + + - - - - - - - - + android:layout_marginTop="8dp" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + - - - - - - - - - + android:textSize="18sp" + android:textStyle="bold" /> - - - - - + android:layout_marginTop="8dp" + android:layout_marginBottom="32dp" + android:orientation="horizontal"> - - - - - - + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 4e71fed..732c809 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -9,7 +9,7 @@ android:id="@+id/navigation_home" android:name="dev.marcosfarias.pokedex.ui.home.HomeFragment" android:label="@string/app_name" - tools:layout="@layout/fragment_home" > + tools:layout="@layout/fragment_home"> + tools:layout="@layout/fragment_pokedex"> @@ -54,31 +54,51 @@ android:id="@+id/navigation_dashboard" android:name="dev.marcosfarias.pokedex.ui.dashboard.DashboardFragment" android:label="@string/app_name" - tools:layout="@layout/fragment_dashboard" /> + tools:layout="@layout/fragment_dashboard"> + + + tools:layout="@layout/fragment_about"> + + + tools:layout="@layout/fragment_moves"> + + + tools:layout="@layout/fragment_evolution"> + + + tools:layout="@layout/fragment_stats"> + + \ No newline at end of file