From 95eaca03ec3644b39d931516d756d0ff8fb144b3 Mon Sep 17 00:00:00 2001 From: Daniele Verducci su MatissePenguin Date: Wed, 1 Sep 2021 19:49:53 +0200 Subject: [PATCH] Filled detail --- .idea/misc.xml | 1 + .idea/runConfigurations.xml | 10 ---------- .../subitobeers/MainActivity.kt | 5 +---- .../subitobeers/ui/BeerDetailFragment.kt | 18 +++++++++++++++--- 4 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 9596f86..7657d6c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,6 +4,7 @@ diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt b/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt index 5bf2c6e..4af2175 100644 --- a/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt +++ b/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity(), BeerNavigation { } override fun showBeerDetail(beer: Beer) { - val detailFragment = BeerDetailFragment() + val detailFragment = BeerDetailFragment(beer) supportFragmentManager.beginTransaction() .replace(R.id.fragment_container, detailFragment) .addToBackStack(null) @@ -25,8 +25,6 @@ class MainActivity : AppCompatActivity(), BeerNavigation { } override fun onBackPressed() { - super.onBackPressed() - val bsf = supportFragmentManager.backStackEntryCount if(bsf == 0) { super.onBackPressed() @@ -35,5 +33,4 @@ class MainActivity : AppCompatActivity(), BeerNavigation { } } - } \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerDetailFragment.kt b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerDetailFragment.kt index cda3432..be47e7f 100644 --- a/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerDetailFragment.kt +++ b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerDetailFragment.kt @@ -5,9 +5,12 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.squareup.picasso.Picasso +import it.danieleverducci.subitobeers.R import it.danieleverducci.subitobeers.databinding.FragmentBeerDetailBinding +import it.danieleverducci.subitobeers.entities.Beer -class BeerDetailFragment : Fragment() { +class BeerDetailFragment(val beer: Beer) : Fragment() { lateinit var binding: FragmentBeerDetailBinding @@ -23,17 +26,26 @@ class BeerDetailFragment : Fragment() { ) // Populate view + Picasso.get() + .load(beer.imageUrl) + .placeholder(R.drawable.ic_launcher_foreground) + .error(R.drawable.ic_launcher_foreground) + .into(binding.beerDetailPic) + binding.beerDetailTitle.text = beer.name + binding.beerDetailShortdesc.text = beer.tagline + binding.beerDetailDesc.text = beer.description +// binding.beerDetailFirstbrewed.text = beer. return binding.root } override fun onStart() { super.onStart() - activity?.actionBar?.setDisplayHomeAsUpEnabled(true); + requireActivity().actionBar?.setDisplayHomeAsUpEnabled(true); } override fun onStop() { super.onStop() - activity?.actionBar?.setDisplayHomeAsUpEnabled(false); + requireActivity().actionBar?.setDisplayHomeAsUpEnabled(false); } } \ No newline at end of file