diff --git a/app/src/main/java/it/danieleverducci/subitobeers/BeerNavigation.kt b/app/src/main/java/it/danieleverducci/subitobeers/BeerNavigation.kt
new file mode 100644
index 0000000..7a79cbd
--- /dev/null
+++ b/app/src/main/java/it/danieleverducci/subitobeers/BeerNavigation.kt
@@ -0,0 +1,7 @@
+package it.danieleverducci.subitobeers
+
+import it.danieleverducci.subitobeers.entities.Beer
+
+interface BeerNavigation {
+ fun showBeerDetail(beer: Beer)
+}
\ 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 44cb609..5bf2c6e 100644
--- a/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt
+++ b/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt
@@ -1,10 +1,11 @@
package it.danieleverducci.subitobeers
-import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
import it.danieleverducci.subitobeers.entities.Beer
+import it.danieleverducci.subitobeers.ui.BeerDetailFragment
-class MainActivity : AppCompatActivity() {
+class MainActivity : AppCompatActivity(), BeerNavigation {
companion object {
val TAG = "MainActivity"
@@ -13,14 +14,26 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
-
}
- fun showBeerDetail(beer: Beer) {
- // TODO
+ override fun showBeerDetail(beer: Beer) {
+ val detailFragment = BeerDetailFragment()
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.fragment_container, detailFragment)
+ .addToBackStack(null)
+ .commit()
}
+ override fun onBackPressed() {
+ super.onBackPressed()
+ val bsf = supportFragmentManager.backStackEntryCount
+ if(bsf == 0) {
+ super.onBackPressed()
+ } else {
+ supportFragmentManager.popBackStack()
+ }
+ }
}
\ 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
new file mode 100644
index 0000000..cda3432
--- /dev/null
+++ b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerDetailFragment.kt
@@ -0,0 +1,39 @@
+package it.danieleverducci.subitobeers.ui
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import it.danieleverducci.subitobeers.databinding.FragmentBeerDetailBinding
+
+class BeerDetailFragment : Fragment() {
+
+ lateinit var binding: FragmentBeerDetailBinding
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentBeerDetailBinding.inflate(
+ LayoutInflater.from(container!!.context),
+ container,
+ false
+ )
+
+ // Populate view
+
+ return binding.root
+ }
+
+ override fun onStart() {
+ super.onStart()
+ activity?.actionBar?.setDisplayHomeAsUpEnabled(true);
+ }
+
+ override fun onStop() {
+ super.onStop()
+ activity?.actionBar?.setDisplayHomeAsUpEnabled(false);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt
index c4597fd..2b3b42c 100644
--- a/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt
+++ b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt
@@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
+import it.danieleverducci.subitobeers.BeerNavigation
import it.danieleverducci.subitobeers.BeersRepository
import it.danieleverducci.subitobeers.R
import it.danieleverducci.subitobeers.entities.Beer
@@ -64,7 +65,10 @@ class BeersFragment : Fragment(), BeersRepository.Listener, BeerRecyclerAdapter.
* Called when an item is clicked in the list
*/
override fun OnItemClicked(item: Beer) {
- TODO("Not yet implemented")
+ if (activity is BeerNavigation)
+ (activity as BeerNavigation).showBeerDetail(item);
+ else
+ throw IllegalStateException("Activity must implement BeerNavigation")
}
/**
diff --git a/app/src/main/res/drawable/ic_firstbrewed.xml b/app/src/main/res/drawable/ic_firstbrewed.xml
new file mode 100644
index 0000000..1cf969c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_firstbrewed.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 3158501..945f000 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -8,7 +8,7 @@
diff --git a/app/src/main/res/layout/fragment_beer_detail.xml b/app/src/main/res/layout/fragment_beer_detail.xml
new file mode 100644
index 0000000..4bb197e
--- /dev/null
+++ b/app/src/main/res/layout/fragment_beer_detail.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_beers_listitem.xml b/app/src/main/res/layout/fragment_beers_listitem.xml
index d33cdf0..b4b7bb0 100644
--- a/app/src/main/res/layout/fragment_beers_listitem.xml
+++ b/app/src/main/res/layout/fragment_beers_listitem.xml
@@ -28,7 +28,7 @@
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
- android:text="Beer name"
+ android:text="@string/placeholder_beertitle"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/beer_item_descr"
@@ -45,7 +45,7 @@
android:layout_marginBottom="16dp"
android:ellipsize="end"
android:maxLines="3"
- android:text="Beer description lorem ipsum dolor sit amet"
+ android:text="@string/placeholder_tagline"
app:layout_constraintBottom_toBottomOf="@+id/beer_item_pic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/beer_item_pic"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 444de70..fc2a888 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -6,4 +6,10 @@
+
+ Beer name
+ Lorem ipsum dolor sit amet
+ 00/0000
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tristique consectetur felis vel pretium. Praesent tincidunt vestibulum lacus, molestie rhoncus lacus fermentum vel. Morbi vel pulvinar sapien, sed ultrices arcu. Vivamus gravida nulla vel ex varius, vel consequat dolor tincidunt. Fusce maximus quis mi eget tristique. Aenean sed facilisis libero. Aliquam volutpat posuere fringilla. Praesent in lorem at elit ornare congue et quis quam. Maecenas tempus et purus ac rhoncus. Donec in pulvinar ex. Aliquam ac vehicula dolor. Nam vitae tortor id nibh congue sollicitudin id in nisi. Proin lorem eros, congue at euismod et, malesuada porta nunc. Proin laoreet massa ac mi lacinia, eget tincidunt odio vestibulum. Vestibulum fermentum nunc nunc, eget ultrices nisi tempor non. Curabitur lorem leo, fringilla et pellentesque a, pharetra id magna.
+
\ No newline at end of file