diff --git a/app/src/main/java/com/example/movieapp/BindingAdapter.kt b/app/src/main/java/com/example/movieapp/BindingAdapter.kt index b567886..cb4a5e0 100644 --- a/app/src/main/java/com/example/movieapp/BindingAdapter.kt +++ b/app/src/main/java/com/example/movieapp/BindingAdapter.kt @@ -51,6 +51,47 @@ fun TextView.bindYear(year: Int?) { } } +//Binding adapter used to display time from object +@BindingAdapter("time") +fun TextView.bindTime(time: String?) { + time?.let { + text = time + } +} + +//Binding adapter used to display language from object +@BindingAdapter("language") +fun TextView.bindLanguage(language: String?) { + language?.let { + text = language + } +} + +//Binding adapter used to display writer from object +@BindingAdapter("writer") +fun TextView.bindWriter(writer: String?) { + writer?.let { + text = writer + } +} + +//Binding adapter used to display actors from object +@BindingAdapter("actors") +fun TextView.bindActors(actors: String?) { + actors?.let { + text = actors + } +} + +//Binding adapter used to display genre from object +@BindingAdapter("genre") +fun TextView.bindGenre(genre: String?) { + genre?.let { + text = genre + } +} + + //Binding adapter used to set adapter of RecyclerView @BindingAdapter("listData") fun bindRecyclerView(recyclerView: RecyclerView, data: List?) { diff --git a/app/src/main/java/com/example/movieapp/MainActivity.kt b/app/src/main/java/com/example/movieapp/MainActivity.kt index 5a4dfee..c041d5d 100644 --- a/app/src/main/java/com/example/movieapp/MainActivity.kt +++ b/app/src/main/java/com/example/movieapp/MainActivity.kt @@ -3,6 +3,8 @@ package com.example.movieapp import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate +import androidx.navigation.fragment.NavHostFragment +import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { @@ -12,5 +14,10 @@ class MainActivity : AppCompatActivity() { //Function for Light-Dark theme AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.getDefaultNightMode()) + + val myNavHostFragment: NavHostFragment = nav_host_fragment as NavHostFragment + val inflater = myNavHostFragment.navController.navInflater + val graph = inflater.inflate(R.navigation.navigation) + myNavHostFragment.navController.graph = graph } } diff --git a/app/src/main/java/com/example/movieapp/database/Room.kt b/app/src/main/java/com/example/movieapp/database/Room.kt index 631d17b..eec0322 100644 --- a/app/src/main/java/com/example/movieapp/database/Room.kt +++ b/app/src/main/java/com/example/movieapp/database/Room.kt @@ -16,7 +16,7 @@ interface MovieDao { } //Create DAO object -@Database(entities = [DatabaseMovie::class], version = 1) +@Database(entities = [DatabaseMovie::class], version = 2) abstract class MovieDatabase : RoomDatabase() { abstract val movieDao: MovieDao } @@ -32,7 +32,7 @@ fun getDatabase(context: Context): MovieDatabase { context.applicationContext, MovieDatabase::class.java, "movies" - ).build() + ).fallbackToDestructiveMigration().build() } } return INSTANCE diff --git a/app/src/main/res/layout/detail_fragment.xml b/app/src/main/res/layout/detail_fragment.xml index 0e69289..e3ba214 100644 --- a/app/src/main/res/layout/detail_fragment.xml +++ b/app/src/main/res/layout/detail_fragment.xml @@ -13,7 +13,7 @@ android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".detail.DetailFragment"> + tools:context=".ui.detail.DetailFragment"> + app:layout_constraintTop_toBottomOf="@+id/toolbar" + android:contentDescription="@string/plot" /> + app:layout_constraintStart_toStartOf="@+id/year_ditale" + app:layout_constraintTop_toBottomOf="@+id/year_ditale" + tools:text="Documentary, History, War" + app:genre="@{viewModel.selectProperty.genre}"/> + app:layout_constraintStart_toStartOf="@+id/genre_ditale" + app:layout_constraintTop_toBottomOf="@+id/genre_ditale" + tools:text="99 min" + app:time="@{viewModel.selectProperty.time}"/> + tools:text="English" + app:language="@{viewModel.selectProperty.language}"/> + app:layout_constraintTop_toBottomOf="@+id/textView5" + app:writer="@{viewModel.selectProperty.writer}" + tools:text="Peter Jackson" /> + app:layout_constraintTop_toBottomOf="@+id/textView6" + tools:text="Mark Kermode, Peter Jackson" /> false #121212 + @color/appColor \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c0f91ed..a2f9cb0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,6 @@ MovieApp + Plot + Writer + Actors diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0257b5d..a61e140 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -3,7 +3,7 @@