Filled detail

This commit is contained in:
Daniele Verducci su MatissePenguin 2021-09-01 19:49:53 +02:00
parent 87be0931b3
commit 95eaca03ec
4 changed files with 17 additions and 17 deletions

View File

@ -4,6 +4,7 @@
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" /> <entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" />
<entry key="app/src/main/res/layout/fragment_beer_detail.xml" value="0.536" />
<entry key="app/src/main/res/layout/fragment_beers_listitem.xml" value="0.5307291666666667" /> <entry key="app/src/main/res/layout/fragment_beers_listitem.xml" value="0.5307291666666667" />
</map> </map>
</option> </option>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity(), BeerNavigation {
} }
override fun showBeerDetail(beer: Beer) { override fun showBeerDetail(beer: Beer) {
val detailFragment = BeerDetailFragment() val detailFragment = BeerDetailFragment(beer)
supportFragmentManager.beginTransaction() supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, detailFragment) .replace(R.id.fragment_container, detailFragment)
.addToBackStack(null) .addToBackStack(null)
@ -25,8 +25,6 @@ class MainActivity : AppCompatActivity(), BeerNavigation {
} }
override fun onBackPressed() { override fun onBackPressed() {
super.onBackPressed()
val bsf = supportFragmentManager.backStackEntryCount val bsf = supportFragmentManager.backStackEntryCount
if(bsf == 0) { if(bsf == 0) {
super.onBackPressed() super.onBackPressed()
@ -35,5 +33,4 @@ class MainActivity : AppCompatActivity(), BeerNavigation {
} }
} }
} }

View File

@ -5,9 +5,12 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment 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.databinding.FragmentBeerDetailBinding
import it.danieleverducci.subitobeers.entities.Beer
class BeerDetailFragment : Fragment() { class BeerDetailFragment(val beer: Beer) : Fragment() {
lateinit var binding: FragmentBeerDetailBinding lateinit var binding: FragmentBeerDetailBinding
@ -23,17 +26,26 @@ class BeerDetailFragment : Fragment() {
) )
// Populate view // 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 return binding.root
} }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
activity?.actionBar?.setDisplayHomeAsUpEnabled(true); requireActivity().actionBar?.setDisplayHomeAsUpEnabled(true);
} }
override fun onStop() { override fun onStop() {
super.onStop() super.onStop()
activity?.actionBar?.setDisplayHomeAsUpEnabled(false); requireActivity().actionBar?.setDisplayHomeAsUpEnabled(false);
} }
} }