Skip to content

Commit

Permalink
Repackage ViewModelKey to annotations pacakage
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Feb 15, 2020
1 parent 2e725f2 commit f12587e
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ open class ViewModelFragment : Fragment() {
inflater: LayoutInflater,
resId: Int,
container: ViewGroup?
): T = DataBindingUtil.inflate<T>(inflater, resId, container, false)
): T = DataBindingUtil.inflate(inflater, resId, container, false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import javax.inject.Provider
import javax.inject.Singleton

@Singleton
class AppViewModelFactory @Inject
constructor(private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>>) :
ViewModelProvider.Factory {
class AppViewModelFactory @Inject constructor(
private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>>
) : ViewModelProvider.Factory {

@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.skydoves.themovies.compose.ViewModelFragment
import dagger.Module
import dagger.android.ContributesAndroidInjector

@Suppress("unused")
@Module
abstract class ComposeModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.skydoves.themovies.view.ui.main.TvListFragment
import dagger.Module
import dagger.android.ContributesAndroidInjector

@Suppress("unused")
@Module
abstract class MainActivityFragmentModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package com.skydoves.themovies.di

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.skydoves.themovies.di.annotations.ViewModelKey
import com.skydoves.themovies.view.ui.details.movie.MovieDetailViewModel
import com.skydoves.themovies.view.ui.details.person.PersonDetailViewModel
import com.skydoves.themovies.view.ui.details.tv.TvDetailViewModel
Expand All @@ -34,7 +35,6 @@ import dagger.Binds
import dagger.Module
import dagger.multibindings.IntoMap

@Suppress("unused")
@Module
internal abstract class ViewModelModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package com.skydoves.themovies.di
package com.skydoves.themovies.di.annotations

import androidx.lifecycle.ViewModel
import dagger.MapKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline fun <reified T> View.bindResource(resource: Resource<T>?, onSuccess: (Res
when (resource.status) {
Status.LOADING -> Unit
Status.SUCCESS -> onSuccess(resource)
Status.ERROR -> this.context.toast(resource.errorEnvelope?.status_message.toString())
Status.ERROR -> context.toast(resource.errorEnvelope?.status_message.toString())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ package com.skydoves.themovies.models.entity

import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.skydoves.themovies.models.Keyword
import com.skydoves.themovies.models.Review
import com.skydoves.themovies.models.Video
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(primaryKeys = [("id")])
@Entity
data class Movie(
@PrimaryKey val id: Int,
var page: Int,
var keywords: List<Keyword>? = ArrayList(),
var videos: List<Video>? = ArrayList(),
Expand All @@ -43,7 +45,6 @@ data class Movie(
val overview: String,
val release_date: String,
val genre_ids: List<Int>,
val id: Int,
val original_title: String,
val original_language: String,
val title: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ package com.skydoves.themovies.models.entity
import android.os.Parcelable
import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.skydoves.themovies.models.network.PersonDetail
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(tableName = "People", primaryKeys = ["id"])
@Entity(tableName = "People")
data class Person(
var page: Int,
@PrimaryKey val id: Int,
@Embedded var personDetail: PersonDetail? = null,
var page: Int,
val profile_path: String?,
val adult: Boolean,
val id: Int,
val name: String,
val popularity: Float
) : Parcelable
5 changes: 3 additions & 2 deletions app/src/main/java/com/skydoves/themovies/models/entity/Tv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ package com.skydoves.themovies.models.entity

import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.skydoves.themovies.models.Keyword
import com.skydoves.themovies.models.Review
import com.skydoves.themovies.models.Video
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(primaryKeys = [("id")])
@Entity
data class Tv(
@PrimaryKey val id: Int,
var page: Int,
var keywords: List<Keyword>? = ArrayList(),
var videos: List<Video>? = ArrayList(),
var reviews: List<Review>? = ArrayList(),
val poster_path: String,
val popularity: Float,
val id: Int,
val backdrop_path: String?,
val vote_average: Float,
val overview: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ import javax.inject.Singleton
import timber.log.Timber

@Singleton
class DiscoverRepository @Inject
constructor(
class DiscoverRepository @Inject constructor(
val discoverService: TheDiscoverService,
val movieDao: MovieDao,
val tvDao: TvDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ import javax.inject.Singleton
import timber.log.Timber

@Singleton
class MovieRepository @Inject
constructor(val service: MovieService, val movieDao: MovieDao) :
Repository {
class MovieRepository @Inject constructor(
val service: MovieService,
val movieDao: MovieDao
) : Repository {

init {
Timber.d("Injection MovieRepository")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ import javax.inject.Singleton
import timber.log.Timber

@Singleton
class PeopleRepository @Inject
constructor(val peopleService: PeopleService, val peopleDao: PeopleDao) :
Repository {
class PeopleRepository @Inject constructor(
val peopleService: PeopleService,
val peopleDao: PeopleDao
) : Repository {

init {
Timber.d("Injection PeopleRepository")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ import javax.inject.Singleton
import timber.log.Timber

@Singleton
class TvRepository @Inject
constructor(val service: TvService, val tvDao: TvDao) :
Repository {
class TvRepository @Inject constructor(
val service: TvService,
val tvDao: TvDao
) : Repository {

init {
Timber.d("Injection TvRepository")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import org.jetbrains.anko.startActivity

class TvDetailActivity : ViewModelActivity(), VideoListViewHolder.Delegate {

private val viewModel by viewModel<TvDetailViewModel>()
private val viewModel: TvDetailViewModel by viewModel()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down

0 comments on commit f12587e

Please sign in to comment.