Skip to content

Commit

Permalink
Сделано отображение дополнительных свединей в Detail Fragment
Browse files Browse the repository at this point in the history
Сделан основной цвет приложения
  • Loading branch information
Slavik Urdzik committed Feb 6, 2020
1 parent caba0c7 commit ab3bc92
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 32 deletions.
41 changes: 41 additions & 0 deletions app/src/main/java/com/example/movieapp/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Movie>?) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/movieapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/movieapp/database/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -32,7 +32,7 @@ fun getDatabase(context: Context): MovieDatabase {
context.applicationContext,
MovieDatabase::class.java,
"movies"
).build()
).fallbackToDestructiveMigration().build()
}
}
return INSTANCE
Expand Down
65 changes: 36 additions & 29 deletions app/src/main/res/layout/detail_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
Expand All @@ -34,7 +34,8 @@
android:src="@android:color/background_dark"
app:imageUrl="@{viewModel.selectProperty.poster}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
app:layout_constraintTop_toBottomOf="@+id/toolbar"
android:contentDescription="@string/plot" />

<TextView
android:id="@+id/title_detail"
Expand All @@ -43,7 +44,6 @@
android:layout_marginStart="24dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="16dp"
android:text="Title"
android:textColor="?attr/actionMenuTextColor"
android:textSize="24sp"
android:textStyle="bold"
Expand All @@ -55,11 +55,10 @@
tools:text="They Shall Not Grow Old" />

<TextView
android:id="@+id/year_detail"
android:id="@+id/year_ditale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/title_detail"
Expand All @@ -68,47 +67,50 @@
app:year="@{viewModel.selectProperty.year}"/>

<TextView
android:id="@+id/genre_detail"
android:layout_marginEnd="16dp"
android:id="@+id/genre_ditale"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/year_detail"
app:layout_constraintTop_toBottomOf="@+id/year_detail"
tools:text="Documentary, History, War" />
app:layout_constraintStart_toStartOf="@+id/year_ditale"
app:layout_constraintTop_toBottomOf="@+id/year_ditale"
tools:text="Documentary, History, War"
app:genre="@{viewModel.selectProperty.genre}"/>

<TextView
android:layout_marginEnd="16dp"
android:id="@+id/runtimes_ditale"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/genre_detail"
app:layout_constraintTop_toBottomOf="@+id/genre_detail"
tools:text="99 min" />
app:layout_constraintStart_toStartOf="@+id/genre_ditale"
app:layout_constraintTop_toBottomOf="@+id/genre_ditale"
tools:text="99 min"
app:time="@{viewModel.selectProperty.time}"/>

<TextView
android:id="@+id/language"
android:layout_marginEnd="16dp"
android:id="@+id/langue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/runtimes_ditale"
app:layout_constraintTop_toBottomOf="@+id/runtimes_ditale"
tools:text="English" />
tools:text="English"
app:language="@{viewModel.selectProperty.language}"/>

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Plot"
android:text="@string/plot"
android:textColor="?attr/editTextColor"
android:textSize="18sp"
android:textStyle="bold"
Expand All @@ -121,7 +123,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="24dp"
android:text="Writer"
android:text="@string/writer"
android:textColor="?attr/editTextColor"
android:textSize="18sp"
android:textStyle="bold"
Expand All @@ -133,33 +135,39 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Actors"
android:text="@string/actors"
android:textColor="?attr/editTextColor"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/textView5"
app:layout_constraintTop_toBottomOf="@+id/textView7" />

<TextView
tools:text="Peter Jackson"
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/textView5"
app:layout_constraintTop_toBottomOf="@+id/textView5" />
app:layout_constraintTop_toBottomOf="@+id/textView5"
app:writer="@{viewModel.selectProperty.writer}"
tools:text="Peter Jackson" />

<TextView
tools:text="Mark Kermode, Peter Jackson"
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
android:layout_marginEnd="16dp"
app:actors="@{viewModel.selectProperty.actors}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/textView7"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
app:layout_constraintTop_toBottomOf="@+id/textView6"
tools:text="Mark Kermode, Peter Jackson" />


<TextView
Expand All @@ -168,7 +176,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/textView4"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
<item name="colorPrimaryDark">#121212</item>
<item name="colorPrimary">@color/appColor</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">MovieApp</string>
<string name="plot">Plot</string>
<string name="writer">Writer</string>
<string name="actors">Actors</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#000</item>
<item name="colorPrimary">@color/appColor</item>
<item name="colorPrimaryDark">#fff</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
Expand Down

0 comments on commit ab3bc92

Please sign in to comment.