Skip to content

Commit

Permalink
Переименовано movieProperty в movie для лучшего понимания
Browse files Browse the repository at this point in the history
Переименовано domian в domain
  • Loading branch information
Slavik Urdzik committed Jan 30, 2020
1 parent 0a597ba commit aeceea5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class DetailFragment : Fragment() {
val binding = DetailFragmentBinding.inflate(inflater)

//Get movie object
val movieProperty = DetailFragmentArgs.fromBundle(arguments!!).movieProperty
val movie = DetailFragmentArgs.fromBundle(arguments!!).movie

val viewModel = ViewModelProvider(this, DetailViewModelFactory(movieProperty))
val viewModel = ViewModelProvider(this, DetailViewModelFactory(movie))
.get(DetailViewModel::class.java)

// Create Toolbar and button of back in toolbar
Expand All @@ -36,7 +36,7 @@ class DetailFragment : Fragment() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayShowTitleEnabled(false)
title = movieProperty.title
title = movie.title
}

//Button of back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.example.movieapp.domain.Movie

class DetailViewModelFactory(private val movieProperty: Movie) : ViewModelProvider.Factory {
class DetailViewModelFactory(private val movie: Movie) : ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(DetailViewModel::class.java)) {
return DetailViewModel(movieProperty) as T
return DetailViewModel(movie) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass



//
@JsonClass(generateAdapter = true)
data class MovieProperty(
@Json(name = "imdbID") val id: String,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/navigation/navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
android:label="DetailFragment"
tools:layout="@layout/detail_fragment">
<argument
android:name="movieProperty"
app:argType="com.example.movieapp.domian.Movie"
android:name="movie"
app:argType="com.example.movieapp.domain.Movie"
/>
<action
android:id="@+id/action_detailFragment_to_overviewFragment"
Expand Down

0 comments on commit aeceea5

Please sign in to comment.