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">
<map>
<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" />
</map>
</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) {
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 {
}
}
}

View File

@ -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);
}
}