From 80a57ee06dd67c4d7e97a10bc3344b30c10df4d1 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Mon, 4 Oct 2021 18:23:34 -0300 Subject: [PATCH 01/41] Complete points 1 to 4 --- .../ScreeningAsyncPagingDataDiffCallback.kt | 14 ----- .../datasource/ScreeningPagingSource.kt | 6 +- .../ui/DetailAndSearchActivity.kt | 9 ++- .../tmdbandroid/home/ui/HomeActivity.kt | 12 ++-- .../tmdbandroid/home/ui/MoviesFragment.kt | 9 ++- .../tmdbandroid/home/ui/TVShowsFragment.kt | 9 ++- .../tmdbandroid/home/ui/WatchlistFragment.kt | 9 +-- .../home/ui/adapters/ScreeningPageAdapter.kt | 1 - .../home/viewmodel/WatchlistViewModel.kt | 3 - .../tmdbandroid/search/ui/SearchFragment.kt | 6 +- .../tmdbandroid/usecase/GetMovieTrailer.kt | 1 - .../tmdbandroid/usecase/GetTVShowTrailer.kt | 1 - app/src/main/res/values/strings.xml | 61 +++++++++++++------ 13 files changed, 77 insertions(+), 64 deletions(-) delete mode 100644 app/src/main/java/com/intive/tmdbandroid/common/ScreeningAsyncPagingDataDiffCallback.kt diff --git a/app/src/main/java/com/intive/tmdbandroid/common/ScreeningAsyncPagingDataDiffCallback.kt b/app/src/main/java/com/intive/tmdbandroid/common/ScreeningAsyncPagingDataDiffCallback.kt deleted file mode 100644 index 97aa51d1..00000000 --- a/app/src/main/java/com/intive/tmdbandroid/common/ScreeningAsyncPagingDataDiffCallback.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.intive.tmdbandroid.common - -import androidx.recyclerview.widget.DiffUtil -import com.intive.tmdbandroid.model.Screening - -class ScreeningAsyncPagingDataDiffCallback : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: Screening, newItem: Screening): Boolean { - return oldItem.id == newItem.id - } - - override fun areContentsTheSame(oldItem: Screening, newItem: Screening): Boolean { - return oldItem == newItem - } -} \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/ScreeningPagingSource.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/ScreeningPagingSource.kt index 46f3148f..2d49ec21 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/ScreeningPagingSource.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/ScreeningPagingSource.kt @@ -10,7 +10,7 @@ class ScreeningPagingSource(private val service: Service, private val type: Int) companion object { const val DEFAULT_PAGE_INDEX = 1 - const val TYPE_TVSHOW = 1 + const val TYPE_TV_SHOW = 1 const val TYPE_MOVIE = 2 } @@ -21,13 +21,13 @@ class ScreeningPagingSource(private val service: Service, private val type: Int) lateinit var screenings: List when (type) { - TYPE_TVSHOW -> { + TYPE_TV_SHOW -> { service.getPaginatedPopularTVShows(pageNumber).collect { screenings = it.toScreeningList() } } TYPE_MOVIE -> { service.getPaginatedPopularMovies(pageNumber).collect { screenings = it.toScreeningList() } } - else -> throw RuntimeException("Ilegal type parameter") + else -> throw RuntimeException("Illegal type parameter") } diff --git a/app/src/main/java/com/intive/tmdbandroid/detailandsearch/ui/DetailAndSearchActivity.kt b/app/src/main/java/com/intive/tmdbandroid/detailandsearch/ui/DetailAndSearchActivity.kt index d241d722..0d81e39f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/detailandsearch/ui/DetailAndSearchActivity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/detailandsearch/ui/DetailAndSearchActivity.kt @@ -13,6 +13,7 @@ class DetailAndSearchActivity : AppCompatActivity() { super.onCreate(savedInstanceState) val binding = ActivityDetailAndSearchBinding.inflate(layoutInflater) setContentView(binding.root) + val context = binding.root.context val navHost = supportFragmentManager.findFragmentById(R.id.nav_host_detail_and_search) as NavHostFragment val navController = navHost.navController @@ -20,9 +21,13 @@ class DetailAndSearchActivity : AppCompatActivity() { val graph = navController .navInflater.inflate(R.navigation.nav_graph) - val action = intent.extras?.getString("action", "search") + val action = intent.extras?.getString( + context.getString(R.string.intent_extra_key_action), + context.getString(R.string.intent_extra_key_action_default) + ) + action.let { - if (it.equals("search")){ + if (it.equals(context.getString(R.string.intent_extra_key_action_default))){ graph.startDestination = R.id.searchFragmentDest } else { graph.startDestination = R.id.detailFragmentDest diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/HomeActivity.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/HomeActivity.kt index 8bca71d9..ca6b089e 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/HomeActivity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/HomeActivity.kt @@ -27,6 +27,8 @@ class HomeActivity : AppCompatActivity() { super.onCreate(savedInstanceState) val binding = ActivityHomeBinding.inflate(layoutInflater) + val context = binding.root.context + setContentView(binding.root) setSupportActionBar(binding.homeToolbar) @@ -46,12 +48,12 @@ class HomeActivity : AppCompatActivity() { if(intent.action == Intent.ACTION_VIEW){ val shareIntent = Intent(this, DetailAndSearchActivity::class.java) val screeningID = intent.data?.lastPathSegment?.toInt() - val mediaType = intent.data?.pathSegments?.get(0) == "movie" + val mediaType = intent.data?.pathSegments?.get(0) == context.getString(R.string.screening_movie_type) shareIntent.putExtras( bundleOf( - "action" to "detail", - "screeningID" to screeningID, - "isMovieBoolean" to mediaType + context.getString(R.string.intent_extra_key_action) to context.getString(R.string.intent_extra_key_action_detail), + context.getString(R.string.intent_extra_key_screening_id) to screeningID, + context.getString(R.string.intent_extra_key_is_movie) to mediaType ) ) startActivity(shareIntent) @@ -73,7 +75,7 @@ class HomeActivity : AppCompatActivity() { val intent = Intent(this, DetailAndSearchActivity::class.java) intent.putExtras( bundleOf( - "action" to "search" + baseContext.getString(R.string.intent_extra_key_action) to baseContext.getString(R.string.intent_extra_key_action_default) ) ) startActivity(intent) diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt index ce5d9204..5953c72d 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt @@ -20,7 +20,6 @@ import com.intive.tmdbandroid.home.viewmodel.MoviesViewModel import com.intive.tmdbandroid.model.Screening import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collect -import timber.log.Timber import kotlin.math.floor @AndroidEntryPoint @@ -37,9 +36,9 @@ class MoviesFragment : Fragment() { val intent = Intent(requireActivity(), DetailAndSearchActivity::class.java) intent.putExtras( bundleOf( - "action" to "detail", - "screeningID" to screening.id, - "isMovieBoolean" to true + (context?.getString(R.string.intent_extra_key_action) ?: "") to (context?.getString(R.string.intent_extra_key_action_detail) ?: ""), + (context?.getString(R.string.intent_extra_key_screening_id) ?: "") to screening.id, + (context?.getString(R.string.intent_extra_key_is_movie) ?: "") to true ) ) requireActivity().startActivity(intent) @@ -70,7 +69,6 @@ class MoviesFragment : Fragment() { private fun subscribePopularData(binding: FragmentMoviesBinding) { lifecycleScope.launchWhenCreated { viewModel.uiState.collect { resultMovies -> - Timber.i("MAS - popular movies status: $resultMovies") when (resultMovies) { is State.Success> -> { @@ -87,6 +85,7 @@ class MoviesFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.errorContainer.visibility = View.GONE } + else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt index d83bd115..fe89f66e 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt @@ -20,7 +20,6 @@ import com.intive.tmdbandroid.home.viewmodel.TVShowsViewModel import com.intive.tmdbandroid.model.Screening import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collect -import timber.log.Timber import kotlin.math.floor @AndroidEntryPoint @@ -36,9 +35,9 @@ class TVShowsFragment : Fragment() { val intent = Intent(requireActivity(), DetailAndSearchActivity::class.java) intent.putExtras( bundleOf( - "action" to "detail", - "screeningID" to screening.id, - "isMovieBoolean" to false + (context?.getString(R.string.intent_extra_key_action) ?: "") to (context?.getString(R.string.intent_extra_key_action_detail) ?: ""), + (context?.getString(R.string.intent_extra_key_screening_id) ?: "") to screening.id, + (context?.getString(R.string.intent_extra_key_is_movie) ?: "") to false ) ) requireActivity().startActivity(intent) @@ -69,7 +68,6 @@ class TVShowsFragment : Fragment() { private fun subscribePopularData(binding: FragmentTvshowsBinding) { lifecycleScope.launchWhenCreated { viewModel.uiState.collect { resultTVShows -> - Timber.i("MAS - popular tvshows status: $resultTVShows") when (resultTVShows) { is State.Success> -> { @@ -86,6 +84,7 @@ class TVShowsFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.errorContainer.visibility = View.GONE } + else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt index c3bf08f5..34d3caed 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt @@ -34,12 +34,12 @@ class WatchlistFragment : Fragment() { super.onCreate(savedInstanceState) val clickListener = { screening: Screening -> val intent = Intent(requireActivity(), DetailAndSearchActivity::class.java) - val isMovie = screening.media_type == "movie" + val isMovie = screening.media_type == context?.getString(R.string.screening_movie_type) intent.putExtras( bundleOf( - "action" to "detail", - "screeningID" to screening.id, - "isMovieBoolean" to isMovie + (context?.getString(R.string.intent_extra_key_action) ?: "") to (context?.getString(R.string.intent_extra_key_action_detail) ?: ""), + (context?.getString(R.string.intent_extra_key_screening_id) ?: "") to screening.id, + (context?.getString(R.string.intent_extra_key_is_movie) ?: "") to isMovie ) ) requireActivity().startActivity(intent) @@ -85,6 +85,7 @@ class WatchlistFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.errorContainer.visibility = View.GONE } + else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index cb686d20..ecaef6d5 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -11,7 +11,6 @@ import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R import com.intive.tmdbandroid.databinding.ItemScreenengSmallBinding import com.intive.tmdbandroid.model.Screening -import com.intive.tmdbandroid.model.TVShow class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : PagingDataAdapter(COMPARATOR) { companion object { diff --git a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt index c14d5372..8ad9af2a 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt @@ -2,12 +2,9 @@ package com.intive.tmdbandroid.home.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import androidx.paging.PagingData -import androidx.paging.cachedIn import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.usecase.GetAllItemsInWatchlistUseCase -import com.intive.tmdbandroid.usecase.PaginatedPopularTVShowsUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt index 6a5667a3..280aeea8 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt @@ -38,7 +38,7 @@ class SearchFragment : Fragment() { super.onCreate(savedInstanceState) val clickListener = { screening: Screening -> - val isMovie = screening.media_type == "movie" + val isMovie = screening.media_type == context?.getString(R.string.screening_movie_type) val action = SearchFragmentDirections.actionSearchFragmentToDetailFragment(screening.id, isMovie) val currentDestination = findNavController().currentDestination?.id @@ -55,7 +55,9 @@ class SearchFragment : Fragment() { savedInstanceState: Bundle? ): View { if (savedInstanceState != null) { - isLoad = savedInstanceState.getBoolean("isLoad", false) + isLoad = savedInstanceState.getBoolean( + context?.getString(R.string.saved_instance_state_is_load), + false) } val binding = FragmentSearchBinding.inflate(inflater, container, false) setupToolbar(binding) diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt index 0d3db725..f6624383 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt @@ -1,6 +1,5 @@ package com.intive.tmdbandroid.usecase -import com.intive.tmdbandroid.model.TVShow import com.intive.tmdbandroid.repository.CatalogRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt index 21dd7861..7c14c147 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt @@ -1,6 +1,5 @@ package com.intive.tmdbandroid.usecase -import com.intive.tmdbandroid.model.TVShow import com.intive.tmdbandroid.repository.CatalogRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46f8c0c9..61c1c074 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,37 +1,62 @@ + To Watch + http + www.intive.towatch.com + + Popular movies + Popular TV shows Watchlist Movies TV shows - Popular movies - Popular TV shows - https://image.tmdb.org/t/p/w780 - https://www.youtube.com/watch?v=%1$s - "%1$d%%" - Oops! Something went wrong.\nSorry about that :( - Nothing to see here - Warning + (%1$s) + + Overview - Add to Watchlist - Share - Search a TV Show or Movie - Start typing to find awesome TV shows - Search Hint Icon Backdrop Poster Header TV Show Poster - Results for: %1$s - (%1$s) Trailer No overview available Rating Icon Rate it Available in: - Network Logo http://www.intive.towatch.com - http - www.intive.towatch.com + + Add to Watchlist + Share + + + Illegal state type + + + "%1$d%%" + https://image.tmdb.org/t/p/w780 + Search a TV Show or Movie + screeningID + isMovieBoolean + action + search + detail + + + Nothing to see here + + + Oops! Something went wrong.\nSorry about that :( + Warning + + + Start typing to find awesome TV shows and Movies + Search Hint Icon + + + Results for: %1$s + movie + isLoad + + %d Season %d Seasons From 91471c4e325d2cc1bc8ec60ed489b924d5915f9c Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Tue, 5 Oct 2021 10:27:37 -0300 Subject: [PATCH 02/41] Resolve points 5,6,7,12 and 13 --- .../tmdbandroid/details/ui/DetailFragment.kt | 7 +++-- .../tmdbandroid/home/ui/WatchlistFragment.kt | 3 +- .../home/ui/adapters/ScreeningPageAdapter.kt | 1 - .../model/converter/CreatedByConverter.kt | 30 ------------------- .../tmdbandroid/search/ui/SearchFragment.kt | 3 +- 5 files changed, 6 insertions(+), 38 deletions(-) delete mode 100644 app/src/main/java/com/intive/tmdbandroid/model/converter/CreatedByConverter.kt diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index 41fd6205..c82d4d12 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -74,7 +74,6 @@ class DetailFragment : Fragment() { super.onViewCreated(view, savedInstanceState) screeningItemId?.let { - Timber.i("MAS - screeningID: $it") if(savedInstanceState==null){ if (isMovie) viewModel.movie(it) else viewModel.tVShows(it) @@ -106,6 +105,7 @@ class DetailFragment : Fragment() { binding.layoutErrorDetail.errorContainer.visibility = View.GONE binding.layoutLoadingDetail.progressBar.visibility = View.VISIBLE } + else -> {} } } } @@ -130,6 +130,7 @@ class DetailFragment : Fragment() { binding.layoutErrorDetail.errorContainer.visibility = View.GONE binding.layoutLoadingDetail.progressBar.visibility = View.VISIBLE } + else -> {} } } } @@ -221,10 +222,10 @@ class DetailFragment : Fragment() { ) { val percentage = (voteAverage * 10).toInt() - binding.popularityRatingNumber.text = "$percentage%" - val context = binding.root.context + binding.popularityRatingNumber.text = context.getString(R.string.popularity, percentage) + when { percentage < 25 -> binding.popularityThumbIcon.imageTintList = ContextCompat.getColorStateList(context, R.color.red) diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt index 34d3caed..86bb6bc9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt @@ -34,12 +34,11 @@ class WatchlistFragment : Fragment() { super.onCreate(savedInstanceState) val clickListener = { screening: Screening -> val intent = Intent(requireActivity(), DetailAndSearchActivity::class.java) - val isMovie = screening.media_type == context?.getString(R.string.screening_movie_type) intent.putExtras( bundleOf( (context?.getString(R.string.intent_extra_key_action) ?: "") to (context?.getString(R.string.intent_extra_key_action_detail) ?: ""), (context?.getString(R.string.intent_extra_key_screening_id) ?: "") to screening.id, - (context?.getString(R.string.intent_extra_key_is_movie) ?: "") to isMovie + (context?.getString(R.string.intent_extra_key_is_movie) ?: "") to (screening.media_type == context?.getString(R.string.screening_movie_type)) ) ) requireActivity().startActivity(intent) diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index ecaef6d5..5fbf851b 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -59,7 +59,6 @@ class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : Pag title.text = item.name try { - //val dateFormat = item.first_air_date?.let { SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(it) } date.text = item.release_date?.let { context.resources.getString(R.string.year, it.substring(0..3)) } } catch (e: Exception) { date.text = "" diff --git a/app/src/main/java/com/intive/tmdbandroid/model/converter/CreatedByConverter.kt b/app/src/main/java/com/intive/tmdbandroid/model/converter/CreatedByConverter.kt deleted file mode 100644 index 77bd4717..00000000 --- a/app/src/main/java/com/intive/tmdbandroid/model/converter/CreatedByConverter.kt +++ /dev/null @@ -1,30 +0,0 @@ -//package com.intive.tmdbandroid.model.converter -// -//import androidx.room.TypeConverter -//import com.google.gson.Gson -//import com.google.gson.reflect.TypeToken -//import com.intive.tmdbandroid.model.CreatedBy -//import java.lang.reflect.Type -// -// -//class CreatedByConverter { -// @TypeConverter // note this annotation -// fun toOptionValuesList(createdByString: String?): List? { -// if (createdByString == null) { -// return null -// } -// val gson = Gson() -// val type = object : TypeToken?>() {}.type -// return gson.fromJson>(createdByString, type) -// } -// -// @TypeConverter -// fun fromOptionValuesList(createdBy: List?): String? { -// if (createdBy == null) { -// return null -// } -// val gson = Gson() -// val type: Type = object : TypeToken?>() {}.type -// return gson.toJson(createdBy, type) -// } -//} \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt index 280aeea8..64e88fa0 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt @@ -38,9 +38,8 @@ class SearchFragment : Fragment() { super.onCreate(savedInstanceState) val clickListener = { screening: Screening -> - val isMovie = screening.media_type == context?.getString(R.string.screening_movie_type) val action = - SearchFragmentDirections.actionSearchFragmentToDetailFragment(screening.id, isMovie) + SearchFragmentDirections.actionSearchFragmentToDetailFragment(screening.id, screening.media_type == context?.getString(R.string.screening_movie_type)) val currentDestination = findNavController().currentDestination?.id if (currentDestination == R.id.searchFragmentDest) { findNavController().navigate(action) From d465e074eabac6ffb38e4d6ac533bd27f814cdb2 Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 11:57:54 -0300 Subject: [PATCH 03/41] Add Timeout to Retrofit --- .../intive/tmdbandroid/common/RetrofitHelper.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/common/RetrofitHelper.kt b/app/src/main/java/com/intive/tmdbandroid/common/RetrofitHelper.kt index 5c04160d..5014e1d9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/common/RetrofitHelper.kt +++ b/app/src/main/java/com/intive/tmdbandroid/common/RetrofitHelper.kt @@ -1,18 +1,24 @@ package com.intive.tmdbandroid.common import com.intive.tmdbandroid.BuildConfig -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory import okhttp3.OkHttpClient - import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.time.Duration object RetrofitHelper { fun getRetrofit() : Retrofit { val interceptor = HttpLoggingInterceptor() interceptor.setLevel(HttpLoggingInterceptor.Level.BODY) - val client = OkHttpClient.Builder().addInterceptor(interceptor).build() + val client = OkHttpClient.Builder() + .addInterceptor(interceptor) + .callTimeout(Duration.ofMinutes(1)) + .connectTimeout(Duration.ofSeconds(30)) + .readTimeout(Duration.ofSeconds(30)) + .writeTimeout(Duration.ofSeconds(30)) + .build() return Retrofit.Builder() .baseUrl(BuildConfig.API_BASE_URL) From 6ab8d8794cf497dee45007464c8045878284aba9 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Tue, 5 Oct 2021 12:03:05 -0300 Subject: [PATCH 04/41] Resolved points 14,15,16 and 17 --- .../com/intive/tmdbandroid/model/CreatedBy.kt | 9 --- .../com/intive/tmdbandroid/model/TVShow.kt | 1 - .../repository/CatalogRepository.kt | 2 +- .../repository/WatchlistRepository.kt | 13 ++-- .../tmdbandroid/search/ui/SearchFragment.kt | 2 +- .../ui/adapters/ScreeningSearchAdapter.kt | 64 +++---------------- .../tmdbandroid/usecase/ExistUseCase.kt | 5 +- .../usecase/GetAllItemsInWatchlistUseCase.kt | 9 ++- .../tmdbandroid/usecase/SearchUseCase.kt | 2 +- .../details/usecase/GetIfExistsUseCaseTest.kt | 4 +- .../usecase/SearchTVShowUseCaseTest.kt | 4 +- 11 files changed, 32 insertions(+), 83 deletions(-) delete mode 100644 app/src/main/java/com/intive/tmdbandroid/model/CreatedBy.kt diff --git a/app/src/main/java/com/intive/tmdbandroid/model/CreatedBy.kt b/app/src/main/java/com/intive/tmdbandroid/model/CreatedBy.kt deleted file mode 100644 index b723b4e6..00000000 --- a/app/src/main/java/com/intive/tmdbandroid/model/CreatedBy.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.intive.tmdbandroid.model - -data class CreatedBy( - val credit_id: String, - val gender: Int, - val id: Int, - val name: String, - val profile_path: String -) \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt index f1df4b75..6ae589de 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt @@ -2,7 +2,6 @@ package com.intive.tmdbandroid.model data class TVShow( val backdrop_path: String?, - val created_by: List, val first_air_date: String?, val genres: List, val id: Int, diff --git a/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt b/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt index d054c470..744735e8 100644 --- a/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt +++ b/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt @@ -53,7 +53,7 @@ class CatalogRepository @Inject constructor( return service.getMovieByID(id) } - fun search(name: String): Flow> { + fun searchByName(name: String): Flow> { return Pager( config = PagingConfig( pageSize = DEFAULT_PAGE_SIZE, diff --git a/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt b/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt index 02dbcaf4..3cd1c078 100644 --- a/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt +++ b/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt @@ -1,6 +1,7 @@ package com.intive.tmdbandroid.repository import com.intive.tmdbandroid.datasource.local.Dao +import com.intive.tmdbandroid.entity.ScreeningORMEntity import com.intive.tmdbandroid.model.Screening import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -9,12 +10,8 @@ import javax.inject.Inject class WatchlistRepository @Inject constructor( private val dao: Dao ) { - suspend fun allFavorites(): Flow> { - return flowOf( - dao.allFavorites().map { - it.toScreening() - } - ) + suspend fun allFavorites(): List { + return dao.allFavorites() } suspend fun insert(screening: Screening) { @@ -25,7 +22,7 @@ class WatchlistRepository @Inject constructor( dao.deleteFavorite(screening.toScreeningORMEntity()) } - suspend fun exist(id: Int): Flow { - return flowOf(dao.existAsFavorite(id)) + suspend fun exist(id: Int): Boolean { + return dao.existAsFavorite(id) } } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt index 64e88fa0..8aee30b0 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt @@ -154,7 +154,7 @@ class SearchFragment : Fragment() { adapter = searchAdapter } lifecycleScope.launchWhenStarted { - searchAdapter.differ.loadStateFlow.collectLatest { loadState -> + searchAdapter.loadStateFlow.collectLatest { loadState -> if (loadState.refresh is LoadState.NotLoading && loadState.append is LoadState.NotLoading && loadState.append.endOfPaginationReached diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt index 2b2aa7e7..a62c7a66 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt @@ -2,11 +2,8 @@ package com.intive.tmdbandroid.search.ui.adapters import android.view.LayoutInflater import android.view.ViewGroup -import androidx.paging.AsyncPagingDataDiffer -import androidx.paging.PagingData -import androidx.recyclerview.widget.AdapterListUpdateCallback +import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListUpdateCallback import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions @@ -19,41 +16,15 @@ import java.util.* class ScreeningSearchAdapter( private val clickListener: ((Screening) -> Unit) -) : RecyclerView.Adapter() { - - val adapterCallback = AdapterListUpdateCallback(this) - - val differ = AsyncPagingDataDiffer( - ScreeningAsyncPagingDataDiffCallback(), - object : ListUpdateCallback { - override fun onInserted(position: Int, count: Int) { - adapterCallback.onInserted(position, count) - } - - override fun onRemoved(position: Int, count: Int) { - adapterCallback.onRemoved(position, count) - } - - override fun onMoved(fromPosition: Int, toPosition: Int) { - adapterCallback.onMoved(fromPosition, toPosition) - } - - override fun onChanged(position: Int, count: Int, payload: Any?) { - adapterCallback.onChanged(position, count, payload) - } - +) : PagingDataAdapter(COMPARATOR) { + companion object { + private val COMPARATOR = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: Screening, newItem: Screening): Boolean = (oldItem == newItem) + override fun areContentsTheSame(oldItem: Screening, newItem: Screening): Boolean = (oldItem == newItem) } - ) - - suspend fun submitData(screening: PagingData) { - differ.submitData(screening) } - override fun getItemCount(): Int { - return differ.itemCount - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchResultHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ScreeningSearchAdapter.SearchResultHolder { return SearchResultHolder( ItemFoundSearchBinding.inflate( LayoutInflater.from(parent.context), @@ -64,7 +35,7 @@ class ScreeningSearchAdapter( } override fun onBindViewHolder(holder: SearchResultHolder, position: Int) { - differ.getItem(position)?.let { holder.bind(it) } + getItem(position)?.let { holder.bind(it) } } inner class SearchResultHolder( @@ -114,25 +85,6 @@ class ScreeningSearchAdapter( .load(posterURL) .apply(options) .into(binding.itemPosterSearch) - - - } - } - - private class ScreeningAsyncPagingDataDiffCallback : DiffUtil.ItemCallback() { - override fun areItemsTheSame( - oldItem: Screening, - newItem: Screening - ): Boolean { - return oldItem.id == newItem.id - } - - override fun areContentsTheSame( - oldItem: Screening, - newItem: Screening - ): Boolean { - return oldItem == newItem } } - } diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt index a704f5a6..78a1ae2c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt @@ -2,10 +2,13 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class ExistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - suspend operator fun invoke(id: Int): Flow = watchlistRepository.exist(id) + suspend operator fun invoke(id: Int): Flow { + return flowOf(watchlistRepository.exist(id)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt index 5f22b368..f87a2a0d 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt @@ -3,10 +3,17 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class GetAllItemsInWatchlistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - suspend operator fun invoke(): Flow> = watchlistRepository.allFavorites() + suspend operator fun invoke(): Flow> { + return flowOf( + watchlistRepository.allFavorites().map { + it.toScreening() + } + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt index 67c86596..2630b65e 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt @@ -8,5 +8,5 @@ import javax.inject.Inject class SearchUseCase @Inject constructor(private val catalogRepository: CatalogRepository) { - operator fun invoke(name:String): Flow> = catalogRepository.search(name) + operator fun invoke(name:String): Flow> = catalogRepository.searchByName(name) } \ No newline at end of file diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt index e2d31be0..46e799f2 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt @@ -42,7 +42,7 @@ class GetIfExistsUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTestEmpty() = mainCoroutineRule.runBlockingTest { - BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(flowOf(false)) + BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(false) val expected = getIfExistsUseCase(2) @@ -56,7 +56,7 @@ class GetIfExistsUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTestNotEmpty() = mainCoroutineRule.runBlockingTest { - BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(flowOf(true)) + BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(true) val expected = getIfExistsUseCase(2) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt index 295516ff..f9f54efd 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt @@ -67,7 +67,7 @@ class SearchTVShowUseCaseTest { @ExperimentalTime fun invokeTest() { mainCoroutineRule.runBlockingTest { - Mockito.`when`(catalogRepository.search(anyString())) + Mockito.`when`(catalogRepository.searchByName(anyString())) .thenReturn( flow { emit( @@ -81,7 +81,7 @@ class SearchTVShowUseCaseTest { Assert.assertEquals(awaitItem(), screening) awaitComplete() } - Mockito.verify(catalogRepository, Mockito.only()).search("cristina kirchner") + Mockito.verify(catalogRepository, Mockito.only()).searchByName("cristina kirchner") } } From ac157f97e955c68880312b381a3e72e1bb8ef86a Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:07:54 -0300 Subject: [PATCH 05/41] Add some order in string resources --- .../home/ui/adapters/ScreeningPageAdapter.kt | 2 -- app/src/main/res/values/strings.xml | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index cb686d20..5fbf851b 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -11,7 +11,6 @@ import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R import com.intive.tmdbandroid.databinding.ItemScreenengSmallBinding import com.intive.tmdbandroid.model.Screening -import com.intive.tmdbandroid.model.TVShow class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : PagingDataAdapter(COMPARATOR) { companion object { @@ -60,7 +59,6 @@ class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : Pag title.text = item.name try { - //val dateFormat = item.first_air_date?.let { SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(it) } date.text = item.release_date?.let { context.resources.getString(R.string.year, it.substring(0..3)) } } catch (e: Exception) { date.text = "" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46f8c0c9..8fa6ed49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,26 +1,29 @@ + To Watch + http://www.intive.towatch.com + http + www.intive.towatch.com + Oops! Something went wrong.\nSorry about that :( + Nothing to see here + Warning + Watchlist Movies TV shows Popular movies Popular TV shows + + https://image.tmdb.org/t/p/w780 https://www.youtube.com/watch?v=%1$s "%1$d%%" - Oops! Something went wrong.\nSorry about that :( - Nothing to see here - Warning Overview Add to Watchlist Share - Search a TV Show or Movie - Start typing to find awesome TV shows - Search Hint Icon Backdrop Poster Header TV Show Poster - Results for: %1$s (%1$s) Trailer No overview available @@ -28,10 +31,6 @@ Rate it Available in: Network Logo - http://www.intive.towatch.com - http - www.intive.towatch.com - %d Season %d Seasons @@ -41,4 +40,11 @@ %d Episode %d Episodes + + + Search a TV Show or Movie + Start typing to find awesome TV shows + Results for: %1$s + Search Hint Icon + \ No newline at end of file From 022aecfe5b4e6db94c7b6fec17900fd75c6f38c6 Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:13:21 -0300 Subject: [PATCH 06/41] Extract contentDescription to string resource in layout/item_found_search.xml --- app/src/main/res/layout/item_found_search.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/item_found_search.xml b/app/src/main/res/layout/item_found_search.xml index 3f1cabbb..152cdf62 100644 --- a/app/src/main/res/layout/item_found_search.xml +++ b/app/src/main/res/layout/item_found_search.xml @@ -77,7 +77,7 @@ android:id="@+id/itemPosterSearch" android:layout_width="66dp" android:layout_height="114dp" - android:contentDescription="TV Show Poster" + android:contentDescription="@string/details_poster_description" android:scaleType="center" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="1:1.5" From 4d72c4ec4f298adcf5589b7b0634361cb2ab488d Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:14:48 -0300 Subject: [PATCH 07/41] Check if layout/item_title.xml is necessary, and remove --- app/src/main/res/layout/item_title.xml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 app/src/main/res/layout/item_title.xml diff --git a/app/src/main/res/layout/item_title.xml b/app/src/main/res/layout/item_title.xml deleted file mode 100644 index 3ccb0ee4..00000000 --- a/app/src/main/res/layout/item_title.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - \ No newline at end of file From 5eeaac692ff8f39dbbdb49713aa9c1a196835e0d Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:17:42 -0300 Subject: [PATCH 08/41] Check if values/ic_launcher_background.xml is necesary, and move value to values/colors.xml --- app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/ic_launcher_background.xml | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 app/src/main/res/values/ic_launcher_background.xml diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3cd3d772..a145f923 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -19,4 +19,6 @@ #5f9d74 #ffffff #000000 + + #F39A0C \ No newline at end of file diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml deleted file mode 100644 index da0e51d5..00000000 --- a/app/src/main/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #F39A0C - \ No newline at end of file From 9d19f2424dc47141bf1d7c25fde9b6eac3d32deb Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:19:07 -0300 Subject: [PATCH 09/41] Move share icon declaration from DetailFragment.kt to layout/watchlist_favorite_detail_fragment.xml --- .../com/intive/tmdbandroid/details/ui/DetailFragment.kt | 9 +++------ .../main/res/menu/watchlist_favorite_detail_fragment.xml | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index c82d4d12..4932c94f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -1,7 +1,7 @@ package com.intive.tmdbandroid.details.ui -import android.content.Intent import android.app.Dialog +import android.content.Intent import android.os.Bundle import android.view.* import android.widget.Toast @@ -15,11 +15,13 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupWithNavController +import androidx.recyclerview.widget.GridLayoutManager import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.databinding.FragmentDetailBinding +import com.intive.tmdbandroid.details.ui.adapters.NetworkAdapter import com.intive.tmdbandroid.details.viewmodel.DetailsViewModel import com.intive.tmdbandroid.model.Screening import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer @@ -33,8 +35,6 @@ import kotlinx.coroutines.launch import timber.log.Timber import java.text.SimpleDateFormat import java.util.* -import androidx.recyclerview.widget.GridLayoutManager -import com.intive.tmdbandroid.details.ui.adapters.NetworkAdapter import kotlin.math.floor @AndroidEntryPoint @@ -275,9 +275,6 @@ class DetailFragment : Fragment() { val toolbar = binding.toolbar toolbar.inflateMenu(R.menu.watchlist_favorite_detail_fragment) - toolbar.menu.findItem(R.id.ic_share).icon = - AppCompatResources.getDrawable(requireContext(), R.drawable.ic_share) - toolbar.setOnMenuItemClickListener { when (it.itemId) { R.id.ic_heart_watchlist -> { diff --git a/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml b/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml index ba4dce72..8c2073c4 100644 --- a/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml +++ b/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml @@ -8,9 +8,9 @@ android:title="@string/add_to_watchlist" app:showAsAction="always"/> - + app:showAsAction="ifRoom"/> \ No newline at end of file From bc6e4453f335e45178c00f46b54d25fcef750737 Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:20:42 -0300 Subject: [PATCH 10/41] Fix typo in layout/item_screeneng_small.xml -> layout/item_screening_small.xml --- .../layout/{item_screeneng_small.xml => item_screening_small.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/res/layout/{item_screeneng_small.xml => item_screening_small.xml} (100%) diff --git a/app/src/main/res/layout/item_screeneng_small.xml b/app/src/main/res/layout/item_screening_small.xml similarity index 100% rename from app/src/main/res/layout/item_screeneng_small.xml rename to app/src/main/res/layout/item_screening_small.xml From b8600c9a9e345c19da0079de7f2e53ad983a4f94 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Tue, 5 Oct 2021 12:37:06 -0300 Subject: [PATCH 11/41] Removed unused model CreatedBy and unused properties from models --- .../1.json | 12 +++--------- .../tmdbandroid/datasource/local/LocalStorageTest.kt | 6 ++---- .../intive/tmdbandroid/entity/MovieListItemEntity.kt | 1 - .../intive/tmdbandroid/entity/ResultTVShowOrMovie.kt | 1 - .../intive/tmdbandroid/entity/ScreeningORMEntity.kt | 2 -- .../tmdbandroid/entity/TVShowListItemEntity.kt | 1 - .../main/java/com/intive/tmdbandroid/model/Movie.kt | 3 --- .../java/com/intive/tmdbandroid/model/Network.kt | 3 --- .../java/com/intive/tmdbandroid/model/Screening.kt | 2 -- .../main/java/com/intive/tmdbandroid/model/TVShow.kt | 2 -- .../usecase/DeleteFromWatchlistUseCaseTest.kt | 3 +-- .../usecase/SaveTVShowInWatchlistUseCaseTest.kt | 3 +-- .../details/viewmodel/DetailsViewModelTest.kt | 9 ++------- .../home/viewmodel/MoviesViewModelTest.kt | 2 -- .../home/viewmodel/TVShowsViewModelTest.kt | 6 ++---- .../home/viewmodel/WatchlistViewModelTest.kt | 3 +-- .../search/viewmodel/SearchViewModelTest.kt | 3 +-- .../tmdbandroid/usecase/DetailTVShowUseCaseTest.kt | 4 +--- .../usecase/PaginatedPopularMoviesUseCaseTest.kt | 2 -- .../usecase/PaginatedPopularTVShowsUseCaseTest.kt | 3 +-- .../tmdbandroid/usecase/SearchTVShowUseCaseTest.kt | 3 +-- 21 files changed, 16 insertions(+), 58 deletions(-) diff --git a/app/schemas/com.intive.tmdbandroid.datasource.local.LocalStorage/1.json b/app/schemas/com.intive.tmdbandroid.datasource.local.LocalStorage/1.json index 51cb522d..3b6b2c93 100644 --- a/app/schemas/com.intive.tmdbandroid.datasource.local.LocalStorage/1.json +++ b/app/schemas/com.intive.tmdbandroid.datasource.local.LocalStorage/1.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 1, - "identityHash": "016e4507f17862924f247000e7d4f1c4", + "identityHash": "5b6de1c98aa9b8ef2331e6efa9ca8915", "entities": [ { "tableName": "ScreeningORMEntity", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `backdrop_path` TEXT, `genres` TEXT, `name` TEXT NOT NULL, `number_of_episodes` INTEGER, `number_of_seasons` INTEGER, `overview` TEXT NOT NULL, `poster_path` TEXT, `status` TEXT, `vote_average` REAL NOT NULL, `vote_count` INTEGER NOT NULL, `popularity` REAL NOT NULL, `release_date` TEXT, `media_type` TEXT NOT NULL, `adult` INTEGER NOT NULL, `genre_ids` TEXT, `video` INTEGER NOT NULL, `networks` TEXT NOT NULL, PRIMARY KEY(`id`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `backdrop_path` TEXT, `genres` TEXT, `name` TEXT NOT NULL, `number_of_episodes` INTEGER, `number_of_seasons` INTEGER, `overview` TEXT NOT NULL, `poster_path` TEXT, `status` TEXT, `vote_average` REAL NOT NULL, `popularity` REAL NOT NULL, `release_date` TEXT, `media_type` TEXT NOT NULL, `adult` INTEGER NOT NULL, `genre_ids` TEXT, `video` INTEGER NOT NULL, `networks` TEXT NOT NULL, PRIMARY KEY(`id`))", "fields": [ { "fieldPath": "id", @@ -68,12 +68,6 @@ "affinity": "REAL", "notNull": true }, - { - "fieldPath": "vote_count", - "columnName": "vote_count", - "affinity": "INTEGER", - "notNull": true - }, { "fieldPath": "popularity", "columnName": "popularity", @@ -130,7 +124,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '016e4507f17862924f247000e7d4f1c4')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5b6de1c98aa9b8ef2331e6efa9ca8915')" ] } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt index 29aea956..94414bba 100644 --- a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt +++ b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt @@ -33,13 +33,12 @@ class LocalStorageTest : TestCase() { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private val screeningUpdate = ScreeningORMEntity( @@ -54,13 +53,12 @@ class LocalStorageTest : TestCase() { poster_path = "POSTER_PATH_2", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) // Override function setUp() and annotate it with @Before diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt index 8cf84279..bcc6bc06 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt @@ -25,7 +25,6 @@ data class MovieListItemEntity( poster_path, null, vote_average, - vote_count, 0.0, release_date, "tv", diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt b/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt index e863ea5f..897359c7 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt @@ -39,7 +39,6 @@ data class ResultTVShowOrMovie( poster_path, null, vote_average, - vote_count, popularity, release_date = release_date ?: first_air_date, media_type, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt index fd109562..59669e78 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt @@ -24,7 +24,6 @@ data class ScreeningORMEntity( val poster_path: String?, val status: String?, val vote_average: Double, - val vote_count: Int, val popularity: Double, val release_date: String?, val media_type: String, @@ -47,7 +46,6 @@ data class ScreeningORMEntity( poster_path, status, vote_average, - vote_count, popularity, release_date, media_type, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt index 4f350a9c..9cc0c416 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt @@ -25,7 +25,6 @@ data class TVShowListItemEntity( poster_path, null, vote_average, - vote_count, 0.0, first_air_date, "tv", diff --git a/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt b/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt index 85be1250..a37293e6 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt @@ -4,14 +4,12 @@ data class Movie( val backdrop_path: String, val genres: List, val id: Int, - val original_title: String, val overview: String, val popularity: Double, val poster_path: String, val release_date: String?, val title: String, val vote_average: Double, - val vote_count: Int, val status: String ) { fun toScreening(): Screening { @@ -26,7 +24,6 @@ data class Movie( poster_path, status, vote_average, - vote_count, popularity, release_date, media_type = "movie", diff --git a/app/src/main/java/com/intive/tmdbandroid/model/Network.kt b/app/src/main/java/com/intive/tmdbandroid/model/Network.kt index 9480e837..9b9f934f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/Network.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/Network.kt @@ -2,7 +2,4 @@ package com.intive.tmdbandroid.model data class Network ( val logo_path: String, - val name: String, - val id: Int, - val origin_country: String ) \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt b/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt index a2cc3ca4..2b88a9f2 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt @@ -13,7 +13,6 @@ data class Screening( val poster_path: String?, val status: String?, val vote_average: Double, - val vote_count: Int, val popularity: Double, val release_date: String?, val media_type: String, @@ -34,7 +33,6 @@ data class Screening( poster_path, status, vote_average, - vote_count, popularity, release_date, media_type, diff --git a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt index 6ae589de..4d8608c4 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt @@ -14,7 +14,6 @@ data class TVShow( val poster_path: String?, val status: String?, val vote_average: Double, - val vote_count: Int, val networks: List ) { fun toScreening(): Screening { @@ -29,7 +28,6 @@ data class TVShow( poster_path, status, vote_average, - vote_count, popularity = 0.0, release_date = first_air_date, media_type = "tv", diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt index 25ff74ce..a2be9039 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt @@ -41,13 +41,12 @@ class DeleteFromWatchlistUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private lateinit var deleteFromWatchlistUseCase: DeleteFromWatchlistUseCase diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt index 4a70aef5..30ef5b62 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt @@ -41,13 +41,12 @@ class SaveTVShowInWatchlistUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private lateinit var saveTVShowInWatchlistUseCase: InsertInWatchlistUseCase diff --git a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt index cb94f34a..a4686b19 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt @@ -41,13 +41,11 @@ class DetailsViewModelTest { overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, - created_by = emptyList(), last_air_date = "1990-09-25", number_of_episodes = 5, number_of_seasons = 2, status = "Online", - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private val movie = Movie( @@ -56,11 +54,9 @@ class DetailsViewModelTest { genres = listOf(Genre(1, "genre1"), Genre(2, "genre2")), id = 1, title = "Simona la Cacarisa", - original_title = "El cochiloco", overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, status = "Online", popularity = 34.0 ) @@ -77,13 +73,12 @@ class DetailsViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private val videoKey = "VIDEO_KEY" diff --git a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModelTest.kt index e6d076a8..2e36c5e8 100644 --- a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModelTest.kt @@ -54,7 +54,6 @@ class MoviesViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "movie", adult = false, @@ -74,7 +73,6 @@ class MoviesViewModelTest { poster_path = "POSTER_PATH_2", status = "Online", vote_average = 15.5, - vote_count = 100, popularity = 80.0, media_type = "movie", adult = false, diff --git a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt index 40ae4217..66e2b350 100644 --- a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt @@ -55,13 +55,12 @@ class TVShowsViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ), Screening( backdrop_path = "BACKDROP_PATH_2", @@ -75,13 +74,12 @@ class TVShowsViewModelTest { poster_path = "POSTER_PATH_2", status = "Online", vote_average = 15.5, - vote_count = 100, popularity = 80.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) ) ) diff --git a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt index 5abc54fd..6e8cc885 100644 --- a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt @@ -40,13 +40,12 @@ class WatchlistViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) ) diff --git a/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt index b6ca97db..788a5502 100644 --- a/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt @@ -44,13 +44,12 @@ class SearchViewModelTest{ poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) ) ) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt index 0fe45865..6bfc45cc 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt @@ -36,13 +36,11 @@ class DetailTVShowUseCaseTest{ overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, - created_by = emptyList(), last_air_date = "1990-09-25", number_of_episodes = 5, number_of_seasons = 2, status = "Online", - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) private lateinit var detailUseCase: DetailTVShowUseCase diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCaseTest.kt index ca3697b8..001380bb 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCaseTest.kt @@ -49,7 +49,6 @@ class PaginatedPopularMoviesUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "movie", adult = false, @@ -69,7 +68,6 @@ class PaginatedPopularMoviesUseCaseTest { poster_path = "POSTER_PATH_2", status = "Online", vote_average = 15.5, - vote_count = 100, popularity = 80.0, media_type = "movie", adult = false, diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt index 957563e5..d78268ed 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt @@ -41,13 +41,12 @@ class PaginatedPopularTVShowsUseCaseTest{ poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) ) ) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt index f9f54efd..959ec59e 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt @@ -43,13 +43,12 @@ class SearchTVShowUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")) + networks = listOf(Network("/netflixlogo.jpg")) ) ) ) From f8c4caa95af436cdb00e7b5e41b9d2f475bfbfbd Mon Sep 17 00:00:00 2001 From: urielgarrido Date: Tue, 5 Oct 2021 12:20:42 -0300 Subject: [PATCH 12/41] Fix typo in layout/item_screeneng_small.xml -> layout/item_screening_small.xml --- .../tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt | 6 +++--- .../{item_screeneng_small.xml => item_screening_small.xml} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename app/src/main/res/layout/{item_screeneng_small.xml => item_screening_small.xml} (100%) diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index 5fbf851b..e1fe860f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R -import com.intive.tmdbandroid.databinding.ItemScreenengSmallBinding +import com.intive.tmdbandroid.databinding.ItemScreeningSmallBinding import com.intive.tmdbandroid.model.Screening class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : PagingDataAdapter(COMPARATOR) { @@ -25,11 +25,11 @@ class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : Pag } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ScreeningHolder = ScreeningHolder( - ItemScreenengSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false), + ItemScreeningSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false), clickListener ) - class ScreeningHolder(binding: ItemScreenengSmallBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { + class ScreeningHolder(binding: ItemScreeningSmallBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { private val title = binding.itemTitle private val backdrop = binding.itemBackdrop private val date = binding.itemDate diff --git a/app/src/main/res/layout/item_screeneng_small.xml b/app/src/main/res/layout/item_screening_small.xml similarity index 100% rename from app/src/main/res/layout/item_screeneng_small.xml rename to app/src/main/res/layout/item_screening_small.xml From b811194827db6fadc189b2a750b7aa5fbdfa2ed8 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 08:29:38 -0300 Subject: [PATCH 13/41] Resolve point 10 --- .../com/intive/tmdbandroid/datasource/network/Service.kt | 1 - .../com/intive/tmdbandroid/entity/MovieListItemEntity.kt | 2 -- .../com/intive/tmdbandroid/entity/TVShowListItemEntity.kt | 2 -- .../tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt | 6 +++--- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt index 00910408..0924839d 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt @@ -9,7 +9,6 @@ import com.intive.tmdbandroid.model.Movie import com.intive.tmdbandroid.model.TVShow import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import timber.log.Timber class Service { private val retrofit = RetrofitHelper.getRetrofit() diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt index bcc6bc06..e9975a93 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt @@ -7,11 +7,9 @@ data class MovieListItemEntity( val release_date: String?, val id: Int, val title: String, - val original_title: String, val overview: String, val poster_path: String?, val vote_average: Double, - val vote_count: Int ) { fun toScreening(): Screening { return Screening( diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt index 9cc0c416..3cbaefe4 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt @@ -7,11 +7,9 @@ data class TVShowListItemEntity( val first_air_date: String?, val id: Int, val name: String, - val original_name: String, val overview: String, val poster_path: String?, val vote_average: Double, - val vote_count: Int ) { fun toScreening(): Screening { return Screening( diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index 5fbf851b..e1fe860f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R -import com.intive.tmdbandroid.databinding.ItemScreenengSmallBinding +import com.intive.tmdbandroid.databinding.ItemScreeningSmallBinding import com.intive.tmdbandroid.model.Screening class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : PagingDataAdapter(COMPARATOR) { @@ -25,11 +25,11 @@ class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : Pag } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ScreeningHolder = ScreeningHolder( - ItemScreenengSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false), + ItemScreeningSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false), clickListener ) - class ScreeningHolder(binding: ItemScreenengSmallBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { + class ScreeningHolder(binding: ItemScreeningSmallBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { private val title = binding.itemTitle private val backdrop = binding.itemBackdrop private val date = binding.itemDate From 4c9cee67f26544768c38111243476d21551714b7 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 08:43:43 -0300 Subject: [PATCH 14/41] Remove differ from SearchFragment.kt --- .../java/com/intive/tmdbandroid/search/ui/SearchFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt index 4fe7aeec..4098df72 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt @@ -196,7 +196,7 @@ class SearchFragment : Fragment() { setFilterSelectedColor(binding, textView) if (viewModel.searchQuery.value.isNotEmpty()) { lifecycleScope.launch { - searchAdapter.differ.submitData(PagingData.empty()) + searchAdapter.submitData(PagingData.empty()) } viewModel.search(viewModel.searchQuery.value) isLoad = true From 9b540695d5cc5cf1b4dcf8929860e9f26ddc946d Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 09:41:07 -0300 Subject: [PATCH 15/41] Resolve point 11 --- .../home/ui/adapters/ScreeningHolder.kt | 62 ------------------- .../home/ui/adapters/WatchlistHolder.kt | 37 ----------- 2 files changed, 99 deletions(-) delete mode 100644 app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningHolder.kt delete mode 100644 app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistHolder.kt diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningHolder.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningHolder.kt deleted file mode 100644 index 742d2429..00000000 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningHolder.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.intive.tmdbandroid.home.ui.adapters - -import androidx.core.content.ContextCompat -import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.intive.tmdbandroid.R -import com.intive.tmdbandroid.databinding.ItemScreeningBinding -import com.intive.tmdbandroid.model.Screening -import java.text.SimpleDateFormat -import java.util.* - -class ScreeningHolder(binding: ItemScreeningBinding, private val clickListener: ((Screening) -> Unit)) : RecyclerView.ViewHolder(binding.root) { - private val poster = binding.screeningPoster - private val popularity = binding.screeningPopularity - private val average = binding.circularPercentage - private val title = binding.screeningTitle - private val date = binding.screeningDate - - private val context = binding.root.context - private val imgUrl = binding.root.resources.getString(R.string.base_imageURL) - - fun bind (item: Screening) { - itemView.setOnClickListener { - clickListener.invoke(item) - } - - val options = RequestOptions() - .centerCrop() - .placeholder(R.drawable.ic_image) - .error(R.drawable.ic_image) - - val posterURL = imgUrl + item.poster_path - - Glide.with(context) - .load(posterURL) - .apply(options) - .into(poster) - - val percentage = (item.vote_average * 10).toInt() - average.progress = percentage - - when { - percentage < 25 -> average.progressTintList = ContextCompat.getColorStateList(context, R.color.red) - percentage < 45 -> average.progressTintList = ContextCompat.getColorStateList(context, R.color.orange) - percentage < 75 -> average.progressTintList = ContextCompat.getColorStateList(context, R.color.yellow) - else -> average.progressTintList = ContextCompat.getColorStateList(context, R.color.green) - } - - popularity.text = context.resources.getString(R.string.popularity, percentage) - - title.text = item.name - - try { - val dateFormat = item.release_date?.let { SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(it) } - val stringDate = dateFormat?.let { SimpleDateFormat("MMM dd, yyyy", Locale.getDefault()).format(it) } - date.text = stringDate - } catch (e: Exception) { - date.text = "" - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistHolder.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistHolder.kt deleted file mode 100644 index 9f7f0b66..00000000 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistHolder.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.intive.tmdbandroid.home.ui.adapters - -import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.intive.tmdbandroid.R -import com.intive.tmdbandroid.databinding.ItemScreeningWatchlistBinding -import com.intive.tmdbandroid.model.Screening - -class WatchlistHolder(binding: ItemScreeningWatchlistBinding, private val clickListener: ((Screening) -> Unit)) : RecyclerView.ViewHolder(binding.root) { - private val title = binding.titleItemWatchlist - private val backdrop = binding.backdropItemWatchlist - - private val context = binding.root.context - private val imgUrl = binding.root.resources.getString(R.string.base_imageURL) - - fun bind (item: Screening) { - itemView.setOnClickListener { - clickListener.invoke(item) - } - - val options = RequestOptions() - .centerCrop() - .placeholder(R.drawable.ic_image) - .error(R.drawable.ic_image) - - val backdropURL = imgUrl + item.backdrop_path - - Glide.with(context) - .load(backdropURL) - .apply(options) - .into(backdrop) - - title.text = item.name - - } -} \ No newline at end of file From 43e7bffeda0d1d2de15fa276649f20df0d0f9265 Mon Sep 17 00:00:00 2001 From: "andres.seoane" Date: Wed, 6 Oct 2021 10:59:57 -0300 Subject: [PATCH 16/41] Make usecases cohesive Merge chip background drawable Merge search icons --- .../repository/WatchlistRepository.kt | 19 ++++++++++++------- .../usecase/DeleteFromWatchlistUseCase.kt | 8 +------- .../usecase/DetailTVShowUseCase.kt | 2 -- .../tmdbandroid/usecase/ExistUseCase.kt | 7 +------ .../usecase/GetAllItemsInWatchlistUseCase.kt | 8 +------- .../tmdbandroid/usecase/GetMovieTrailer.kt | 2 -- .../tmdbandroid/usecase/GetTVShowTrailer.kt | 2 -- .../usecase/InsertInWatchlistUseCase.kt | 8 +------- .../usecase/PaginatedPopularMoviesUseCase.kt | 2 -- .../usecase/PaginatedPopularTVShowsUseCase.kt | 2 -- .../tmdbandroid/usecase/SearchUseCase.kt | 1 - .../main/res/drawable/border_text_view.xml | 6 ------ .../{bg_status.xml => chip_background.xml} | 3 +-- app/src/main/res/drawable/ic_search.xml | 13 +++++++++---- app/src/main/res/drawable/ic_search_hint.xml | 5 ----- app/src/main/res/layout/fragment_detail.xml | 3 ++- app/src/main/res/layout/fragment_search.xml | 12 ++++++++---- app/src/main/res/layout/item_found_search.xml | 3 ++- .../main/res/layout/layout_search_hint.xml | 7 ++++--- 19 files changed, 42 insertions(+), 71 deletions(-) delete mode 100644 app/src/main/res/drawable/border_text_view.xml rename app/src/main/res/drawable/{bg_status.xml => chip_background.xml} (50%) delete mode 100644 app/src/main/res/drawable/ic_search_hint.xml diff --git a/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt b/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt index 3cd1c078..c42889f6 100644 --- a/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt +++ b/app/src/main/java/com/intive/tmdbandroid/repository/WatchlistRepository.kt @@ -1,7 +1,6 @@ package com.intive.tmdbandroid.repository import com.intive.tmdbandroid.datasource.local.Dao -import com.intive.tmdbandroid.entity.ScreeningORMEntity import com.intive.tmdbandroid.model.Screening import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -10,19 +9,25 @@ import javax.inject.Inject class WatchlistRepository @Inject constructor( private val dao: Dao ) { - suspend fun allFavorites(): List { - return dao.allFavorites() + suspend fun allFavorites(): Flow> { + return flowOf( + dao.allFavorites().map { + it.toScreening() + } + ) } - suspend fun insert(screening: Screening) { + suspend fun insert(screening: Screening) : Flow { dao.insertFavorite(screening.toScreeningORMEntity()) + return flowOf(true) } - suspend fun delete(screening: Screening) { + suspend fun delete(screening: Screening) : Flow { dao.deleteFavorite(screening.toScreeningORMEntity()) + return flowOf(false) } - suspend fun exist(id: Int): Boolean { - return dao.existAsFavorite(id) + suspend fun exist(id: Int): Flow { + return flowOf(dao.existAsFavorite(id)) } } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/DeleteFromWatchlistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/DeleteFromWatchlistUseCase.kt index b3195f2f..09f3d5c9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/DeleteFromWatchlistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/DeleteFromWatchlistUseCase.kt @@ -3,14 +3,8 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class DeleteFromWatchlistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - - suspend operator fun invoke(screening: Screening): Flow { - watchlistRepository.delete(screening) - return flowOf(false) - } - + suspend operator fun invoke(screening: Screening): Flow = watchlistRepository.delete(screening) } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCase.kt index 1bcecbe0..223b16e1 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCase.kt @@ -6,7 +6,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class DetailTVShowUseCase @Inject constructor(private val repository: CatalogRepository) { - operator fun invoke(id:Int): Flow = repository.getTVShowByID(id) - } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt index 78a1ae2c..2b59a042 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/ExistUseCase.kt @@ -2,13 +2,8 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class ExistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - - suspend operator fun invoke(id: Int): Flow { - return flowOf(watchlistRepository.exist(id)) - } - + suspend operator fun invoke(id: Int): Flow = watchlistRepository.exist(id) } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt index f87a2a0d..317a2b5f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt @@ -8,12 +8,6 @@ import javax.inject.Inject class GetAllItemsInWatchlistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - suspend operator fun invoke(): Flow> { - return flowOf( - watchlistRepository.allFavorites().map { - it.toScreening() - } - ) - } + suspend operator fun invoke(): Flow> = watchlistRepository.allFavorites() } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt index f6624383..28eb04cc 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt @@ -5,7 +5,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class GetMovieTrailer @Inject constructor(private val repository: CatalogRepository) { - operator fun invoke(id:Int): Flow = repository.getMovieTrailer(id) - } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt index 7c14c147..2b79c135 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt @@ -5,7 +5,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class GetTVShowTrailer @Inject constructor(private val repository: CatalogRepository) { - operator fun invoke(id:Int): Flow = repository.getTVShowTrailer(id) - } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/InsertInWatchlistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/InsertInWatchlistUseCase.kt index f79592d5..2264bb15 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/InsertInWatchlistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/InsertInWatchlistUseCase.kt @@ -3,14 +3,8 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class InsertInWatchlistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { - - suspend operator fun invoke(screening: Screening): Flow { - watchlistRepository.insert(screening) - return flowOf(true) - } - + suspend operator fun invoke(screening: Screening): Flow = watchlistRepository.insert(screening) } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCase.kt index 2b0767d1..fcd97886 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularMoviesUseCase.kt @@ -7,7 +7,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class PaginatedPopularMoviesUseCase @Inject constructor(private val catalogRepository: CatalogRepository) { - operator fun invoke(): Flow> = catalogRepository.paginatedPopularMovies() - } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCase.kt index c758fa0a..efdfac01 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCase.kt @@ -7,7 +7,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class PaginatedPopularTVShowsUseCase @Inject constructor(private val catalogRepository: CatalogRepository) { - operator fun invoke(): Flow> = catalogRepository.paginatedPopularTVShows() - } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt index 001c00aa..244a06b4 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/SearchUseCase.kt @@ -7,6 +7,5 @@ import kotlinx.coroutines.flow.Flow import javax.inject.Inject class SearchUseCase @Inject constructor(private val catalogRepository: CatalogRepository) { - operator fun invoke(name:String, filterSelected: String?): Flow> = catalogRepository.searchByName(name, filterSelected) } \ No newline at end of file diff --git a/app/src/main/res/drawable/border_text_view.xml b/app/src/main/res/drawable/border_text_view.xml deleted file mode 100644 index 596c6847..00000000 --- a/app/src/main/res/drawable/border_text_view.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_status.xml b/app/src/main/res/drawable/chip_background.xml similarity index 50% rename from app/src/main/res/drawable/bg_status.xml rename to app/src/main/res/drawable/chip_background.xml index 2d8ec1c3..1f20beee 100644 --- a/app/src/main/res/drawable/bg_status.xml +++ b/app/src/main/res/drawable/chip_background.xml @@ -1,6 +1,5 @@ - + - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml index e2dd96c6..3a08e3cf 100644 --- a/app/src/main/res/drawable/ic_search.xml +++ b/app/src/main/res/drawable/ic_search.xml @@ -1,5 +1,10 @@ - - + + + + diff --git a/app/src/main/res/drawable/ic_search_hint.xml b/app/src/main/res/drawable/ic_search_hint.xml deleted file mode 100644 index 7ccdb5eb..00000000 --- a/app/src/main/res/drawable/ic_search_hint.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index d9038bf7..123770f6 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -139,7 +139,8 @@ android:textColor="@color/black" android:paddingVertical="2dp" android:paddingHorizontal="12dp" - android:background="@drawable/bg_status" + android:background="@drawable/chip_background" + android:backgroundTint="@color/secondaryLightColor" app:layout_constraintTop_toTopOf="@+id/overview_textView" app:layout_constraintBottom_toBottomOf="@+id/overview_textView" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index 631be2c0..63a712b4 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -36,7 +36,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:background="@drawable/bg_status" + android:background="@drawable/chip_background" + android:backgroundTint="@color/secondaryLightColor" android:paddingHorizontal="16dp" android:paddingVertical="2dp" android:text="@string/all_filter" @@ -51,7 +52,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:background="@drawable/bg_status" + android:background="@drawable/chip_background" + android:backgroundTint="@color/secondaryLightColor" android:paddingHorizontal="16dp" android:paddingVertical="2dp" android:text="@string/tv_shows_filter" @@ -65,7 +67,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:background="@drawable/bg_status" + android:background="@drawable/chip_background" + android:backgroundTint="@color/secondaryLightColor" android:paddingHorizontal="16dp" android:paddingVertical="2dp" android:text="@string/movies_filter" @@ -79,7 +82,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:background="@drawable/bg_status" + android:background="@drawable/chip_background" + android:backgroundTint="@color/secondaryLightColor" android:paddingHorizontal="16dp" android:paddingVertical="2dp" android:text="@string/people_filter" diff --git a/app/src/main/res/layout/item_found_search.xml b/app/src/main/res/layout/item_found_search.xml index 152cdf62..40b0e45f 100644 --- a/app/src/main/res/layout/item_found_search.xml +++ b/app/src/main/res/layout/item_found_search.xml @@ -23,7 +23,8 @@ android:layout_marginStart="5dp" android:layout_marginTop="5dp" android:layout_marginEnd="5dp" - android:background="@drawable/border_text_view" + android:background="@drawable/chip_background" + android:backgroundTint="@color/primaryColor" android:gravity="center" android:padding="5dp" android:textColor="@color/secondaryColor" diff --git a/app/src/main/res/layout/layout_search_hint.xml b/app/src/main/res/layout/layout_search_hint.xml index 47f9149d..613e0c87 100644 --- a/app/src/main/res/layout/layout_search_hint.xml +++ b/app/src/main/res/layout/layout_search_hint.xml @@ -9,11 +9,12 @@ Date: Wed, 6 Oct 2021 11:17:03 -0300 Subject: [PATCH 17/41] Refactor use case name --- .../details/viewmodel/DetailsViewModel.kt | 8 ++++---- ...{GetMovieTrailer.kt => GetMovieTrailerUseCase.kt} | 2 +- ...etTVShowTrailer.kt => GetTVShowTrailerUseCase.kt} | 2 +- .../details/viewmodel/DetailsViewModelTest.kt | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) rename app/src/main/java/com/intive/tmdbandroid/usecase/{GetMovieTrailer.kt => GetMovieTrailerUseCase.kt} (72%) rename app/src/main/java/com/intive/tmdbandroid/usecase/{GetTVShowTrailer.kt => GetTVShowTrailerUseCase.kt} (71%) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt index 686d4b38..3b46605d 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt @@ -18,8 +18,8 @@ class DetailsViewModel @Inject internal constructor( private val insertInWatchlistUseCase: InsertInWatchlistUseCase, private val deleteFromWatchlistUseCase: DeleteFromWatchlistUseCase, private val existUseCase: ExistUseCase, - private val tvShowTrailerUseCase: GetTVShowTrailer, - private val movieTrailerUseCase: GetMovieTrailer + private val tvShowTrailerUseCaseUseCase: GetTVShowTrailerUseCase, + private val movieTrailerUseCaseUseCase: GetMovieTrailerUseCase ) : ViewModel() { private val _state = MutableStateFlow>(State.Waiting) @@ -45,7 +45,7 @@ class DetailsViewModel @Inject internal constructor( fun getTVShowTrailer(id: Int) { viewModelScope.launch { - tvShowTrailerUseCase(id) + tvShowTrailerUseCaseUseCase(id) .catch { _trailerState.send(State.Error) } @@ -69,7 +69,7 @@ class DetailsViewModel @Inject internal constructor( fun getMovieTrailer(id: Int) { viewModelScope.launch { - movieTrailerUseCase(id) + movieTrailerUseCaseUseCase(id) .catch { _trailerState.send(State.Error) } diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailerUseCase.kt similarity index 72% rename from app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt rename to app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailerUseCase.kt index 28eb04cc..15f50aa9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetMovieTrailerUseCase.kt @@ -4,6 +4,6 @@ import com.intive.tmdbandroid.repository.CatalogRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject -class GetMovieTrailer @Inject constructor(private val repository: CatalogRepository) { +class GetMovieTrailerUseCase @Inject constructor(private val repository: CatalogRepository) { operator fun invoke(id:Int): Flow = repository.getMovieTrailer(id) } \ No newline at end of file diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailerUseCase.kt similarity index 71% rename from app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt rename to app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailerUseCase.kt index 2b79c135..e5236f38 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailer.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetTVShowTrailerUseCase.kt @@ -4,6 +4,6 @@ import com.intive.tmdbandroid.repository.CatalogRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject -class GetTVShowTrailer @Inject constructor(private val repository: CatalogRepository) { +class GetTVShowTrailerUseCase @Inject constructor(private val repository: CatalogRepository) { operator fun invoke(id:Int): Flow = repository.getTVShowTrailer(id) } \ No newline at end of file diff --git a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt index a4686b19..adf9f87f 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt @@ -95,9 +95,9 @@ class DetailsViewModelTest { @Mock private lateinit var movieUseCase: DetailMovieUseCase @Mock - private lateinit var tvShowTrailerUseCase: GetTVShowTrailer + private lateinit var tvShowTrailerUseCaseUseCase: GetTVShowTrailerUseCase @Mock - private lateinit var movieTrailerUseCase: GetMovieTrailer + private lateinit var movieTrailerUseCaseUseCase: GetMovieTrailerUseCase @Before @@ -108,8 +108,8 @@ class DetailsViewModelTest { saveTVShowInWatchlistUseCase, deleteFromWatchlistUseCase, getIfExistsUseCase, - tvShowTrailerUseCase, - movieTrailerUseCase + tvShowTrailerUseCaseUseCase, + movieTrailerUseCaseUseCase ) } @@ -245,7 +245,7 @@ class DetailsViewModelTest { @Test @ExperimentalTime fun getTVShowTrailerTest() = mainCoroutineRule.runBlockingTest { - `when`(tvShowTrailerUseCase(anyInt())).thenReturn( + `when`(tvShowTrailerUseCaseUseCase(anyInt())).thenReturn( flow { emit( videoKey @@ -263,7 +263,7 @@ class DetailsViewModelTest { @Test @ExperimentalTime fun getMovieTrailerTest() = mainCoroutineRule.runBlockingTest { - `when`(movieTrailerUseCase(anyInt())).thenReturn( + `when`(movieTrailerUseCaseUseCase(anyInt())).thenReturn( flow { emit( videoKey From 4ae39bc83b7b7bc8097411322133a3b2171fb5e5 Mon Sep 17 00:00:00 2001 From: "andres.seoane" Date: Wed, 6 Oct 2021 13:47:45 -0300 Subject: [PATCH 18/41] Extract margins and paddings to values/dimens.xml resource file --- app/src/main/res/layout/activity_home.xml | 2 +- app/src/main/res/layout/fragment_detail.xml | 50 +++++++++---------- app/src/main/res/layout/fragment_movies.xml | 1 - app/src/main/res/layout/fragment_search.xml | 36 +++++-------- app/src/main/res/layout/fragment_tvshows.xml | 1 - .../main/res/layout/fragment_watchlist.xml | 2 - app/src/main/res/layout/item_found_search.xml | 20 +++----- .../main/res/layout/item_recommendation.xml | 11 ++-- app/src/main/res/layout/item_screening.xml | 24 ++++----- .../main/res/layout/item_screening_small.xml | 19 ++++--- .../res/layout/item_screening_watchlist.xml | 13 +++-- app/src/main/res/layout/layout_error.xml | 2 +- .../main/res/layout/layout_search_hint.xml | 6 +-- app/src/main/res/values/dimens.xml | 13 +++++ app/src/main/res/values/strings.xml | 2 +- 15 files changed, 94 insertions(+), 108 deletions(-) create mode 100644 app/src/main/res/values/dimens.xml diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index e03e107f..3c763f4f 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -32,7 +32,7 @@ android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="5dp" + android:padding="@dimen/margin_spacing" android:background="@color/primaryColor" app:itemIconTint="@color/bottom_nav_selector" app:itemTextColor="@color/bottom_nav_selector" diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index eb28496c..35a83440 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -16,9 +16,8 @@ + android:layout_height="wrap_content" + android:fitsSystemWindows="true"> @@ -74,7 +73,7 @@ + android:layout_margin="@dimen/margin_medium"> @@ -126,9 +125,9 @@ android:layout_height="wrap_content" android:text="@string/overview" android:textColor="@color/black" - android:textSize="20sp" + android:textSize="@dimen/title_size" android:textStyle="bold" - android:layout_marginTop="32dp" + android:layout_marginTop="@dimen/margin_large" app:layout_constraintTop_toBottomOf="@+id/genres_detail_textView" app:layout_constraintStart_toStartOf="parent"/> @@ -137,8 +136,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" - android:paddingVertical="2dp" - android:paddingHorizontal="12dp" + android:paddingHorizontal="@dimen/margin_short" android:background="@drawable/chip_background" android:backgroundTint="@color/secondaryLightColor" app:layout_constraintTop_toTopOf="@+id/overview_textView" @@ -151,7 +149,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" - android:layout_marginTop="24dp" + android:layout_marginTop="@dimen/margin_large" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/overview_detail_textView" tools:text="Aug 23, 2021" /> @@ -161,7 +159,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" - android:layout_marginStart="20dp" + android:layout_marginStart="@dimen/margin_large" app:layout_constraintStart_toEndOf="@+id/first_air_date_detail_textView" app:layout_constraintTop_toTopOf="@+id/first_air_date_detail_textView" tools:text="1 Season" /> @@ -171,7 +169,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" - android:layout_marginStart="20dp" + android:layout_marginStart="@dimen/margin_large" app:layout_constraintStart_toEndOf="@+id/number_of_seasons_detail_textView" app:layout_constraintTop_toTopOf="@id/number_of_seasons_detail_textView" tools:text="12 Episodes" /> @@ -181,8 +179,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="8dp" - android:paddingHorizontal="5dp" - android:drawablePadding="3dp" + android:paddingHorizontal="@dimen/margin_short" + android:drawablePadding="@dimen/margin_spacing" android:gravity="end|center_vertical" android:text="@string/watch_trailer" app:drawableStartCompat="@drawable/ic_play_filled" @@ -195,10 +193,10 @@ android:id="@+id/overview_detail_textView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:lineSpacingExtra="4dp" + android:layout_marginTop="@dimen/margin_short" + android:lineSpacingExtra="@dimen/margin_spacing" android:textColor="@color/black" - android:textSize="16sp" + android:textSize="@dimen/subtitle_size" app:layout_constraintTop_toBottomOf="@id/overview_textView" app:layout_constraintStart_toStartOf="parent" android:layout_marginVertical="20dp" @@ -210,9 +208,9 @@ android:layout_height="wrap_content" android:text="@string/networks_header_text" android:textColor="@color/black" - android:textSize="20sp" + android:textSize="@dimen/title_size" android:textStyle="bold" - android:layout_marginTop="32dp" + android:layout_marginTop="@dimen/margin_large" app:layout_constraintTop_toBottomOf="@+id/first_air_date_detail_textView" app:layout_constraintStart_toStartOf="parent"/> @@ -220,8 +218,8 @@ android:id="@+id/network_list" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="12dp" - android:layout_marginStart="4dp" + android:layout_marginTop="@dimen/margin_short" + android:layout_marginStart="@dimen/margin_spacing" app:layout_constraintTop_toBottomOf="@+id/networks_header" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/fragment_movies.xml b/app/src/main/res/layout/fragment_movies.xml index cbba76a2..f2df46f1 100644 --- a/app/src/main/res/layout/fragment_movies.xml +++ b/app/src/main/res/layout/fragment_movies.xml @@ -18,7 +18,6 @@ + android:searchIcon="@null" /> @@ -35,11 +33,10 @@ android:id="@+id/all_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="@dimen/margin_short" android:background="@drawable/chip_background" android:backgroundTint="@color/secondaryLightColor" - android:paddingHorizontal="16dp" - android:paddingVertical="2dp" + android:paddingHorizontal="@dimen/margin_medium" android:text="@string/all_filter" android:textColor="@color/black" app:layout_constraintEnd_toStartOf="@+id/tv_shows_filter" @@ -51,11 +48,10 @@ android:id="@+id/tv_shows_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="@dimen/margin_short" android:background="@drawable/chip_background" android:backgroundTint="@color/secondaryLightColor" - android:paddingHorizontal="16dp" - android:paddingVertical="2dp" + android:paddingHorizontal="@dimen/margin_medium" android:text="@string/tv_shows_filter" android:textColor="@color/black" app:layout_constraintEnd_toStartOf="@+id/movies_filter" @@ -66,11 +62,10 @@ android:id="@+id/movies_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="@dimen/margin_short" android:background="@drawable/chip_background" android:backgroundTint="@color/secondaryLightColor" - android:paddingHorizontal="16dp" - android:paddingVertical="2dp" + android:paddingHorizontal="@dimen/margin_medium" android:text="@string/movies_filter" android:textColor="@color/black" app:layout_constraintEnd_toStartOf="@+id/people_filter" @@ -81,11 +76,10 @@ android:id="@+id/people_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="@dimen/margin_short" android:background="@drawable/chip_background" android:backgroundTint="@color/secondaryLightColor" - android:paddingHorizontal="16dp" - android:paddingVertical="2dp" + android:paddingHorizontal="@dimen/margin_medium" android:text="@string/people_filter" android:textColor="@color/black" app:layout_constraintEnd_toEndOf="parent" @@ -96,9 +90,8 @@ android:id="@+id/result_search_header" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginBottom="16dp" - android:paddingHorizontal="16dp" + android:layout_marginVertical="@dimen/margin_medium" + android:paddingHorizontal="@dimen/margin_medium" app:layout_constraintBottom_toTopOf="@id/search_results" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -109,7 +102,6 @@ android:id="@+id/search_results" android:layout_width="match_parent" android:layout_height="0dp" - android:paddingBottom="16dp" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -120,15 +112,13 @@ + layout="@layout/layout_error" /> + android:layout_margin="@dimen/margin_short" + app:cardCornerRadius="@dimen/corner_radius" + app:cardElevation="@dimen/elevation"> + android:layout_margin="@dimen/margin_short" + app:cardCornerRadius="@dimen/corner_radius" + app:cardElevation="@dimen/elevation"> @@ -58,7 +56,7 @@ android:id="@+id/popularity_card" android:layout_width="wrap_content" android:layout_height="0dp" - android:layout_marginStart="15dp" + android:layout_marginStart="@dimen/margin_medium" app:cardBackgroundColor="@color/primaryColor" app:cardCornerRadius="100dp" app:cardElevation="3dp" @@ -73,7 +71,7 @@ style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="2dp" + android:layout_margin="@dimen/margin_spacing_small" android:indeterminate="false" android:max="100" android:rotation="-90" @@ -87,7 +85,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:textColor="@color/secondaryColor" - android:textSize="12sp" + android:textSize="@dimen/comment_size" android:textStyle="bold" tools:text="100%" /> diff --git a/app/src/main/res/layout/item_screening_small.xml b/app/src/main/res/layout/item_screening_small.xml index 6cdc5d98..8eac45a5 100644 --- a/app/src/main/res/layout/item_screening_small.xml +++ b/app/src/main/res/layout/item_screening_small.xml @@ -6,9 +6,9 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="8dp" - app:cardCornerRadius="5dp" - app:cardElevation="5dp"> + android:layout_margin="@dimen/margin_short" + app:cardCornerRadius="@dimen/corner_radius" + app:cardElevation="@dimen/elevation"> diff --git a/app/src/main/res/layout/item_screening_watchlist.xml b/app/src/main/res/layout/item_screening_watchlist.xml index 9687db51..59595bb4 100644 --- a/app/src/main/res/layout/item_screening_watchlist.xml +++ b/app/src/main/res/layout/item_screening_watchlist.xml @@ -6,10 +6,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="8dp" - android:paddingBottom="8dp" - app:cardCornerRadius="5dp" - app:cardElevation="4dp"> + android:layout_margin="@dimen/margin_short" + app:cardCornerRadius="@dimen/corner_radius" + app:cardElevation="@dimen/elevation"> + @@ -30,13 +30,12 @@ android:id="@+id/title_item_watchlist" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="8dp" + android:layout_margin="@dimen/margin_short" app:layout_constraintBottom_toBottomOf="parent" android:ellipsize="end" - android:maxWidth="180dp" android:maxLines="1" android:textColor="@color/black" - android:textSize="14sp" + android:textSize="@dimen/subtitle_size" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/backdrop_item_watchlist" diff --git a/app/src/main/res/layout/layout_error.xml b/app/src/main/res/layout/layout_error.xml index 0e32276e..f6807533 100644 --- a/app/src/main/res/layout/layout_error.xml +++ b/app/src/main/res/layout/layout_error.xml @@ -13,7 +13,7 @@ android:id="@+id/error_image" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginVertical="16dp" + android:layout_marginVertical="@dimen/margin_medium" android:src="@drawable/ic_warning" android:contentDescription="@string/warning" app:layout_constraintBottom_toTopOf="@id/error_text" diff --git a/app/src/main/res/layout/layout_search_hint.xml b/app/src/main/res/layout/layout_search_hint.xml index 613e0c87..249a7347 100644 --- a/app/src/main/res/layout/layout_search_hint.xml +++ b/app/src/main/res/layout/layout_search_hint.xml @@ -22,13 +22,13 @@ + + 8dp + 16dp + 24dp + 5dp + 5dp + 20sp + 16sp + 12sp + 4dp + 2dp + \ 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 72f6f498..ed1a5e8e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,7 +48,7 @@ Warning - Start typing to find awesome TV shows and Movies + Start typing to find awesome\nTV shows and Movies Search Hint Icon From 64d49654e13b8a2f66caf9d2eace9607d45cb89b Mon Sep 17 00:00:00 2001 From: "andres.seoane" Date: Wed, 6 Oct 2021 13:50:53 -0300 Subject: [PATCH 19/41] Refactor watchlist_favorite_detail_fragment.xml -> detail_fragment_menu.xml --- .../java/com/intive/tmdbandroid/details/ui/DetailFragment.kt | 2 +- ...st_favorite_detail_fragment.xml => detail_fragment_menu.xml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename app/src/main/res/menu/{watchlist_favorite_detail_fragment.xml => detail_fragment_menu.xml} (100%) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index c676e79b..d68f85ac 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -319,7 +319,7 @@ class DetailFragment : Fragment() { val toolbar = binding.toolbar - toolbar.inflateMenu(R.menu.watchlist_favorite_detail_fragment) + toolbar.inflateMenu(R.menu.detail_fragment_menu) toolbar.setOnMenuItemClickListener { when (it.itemId) { R.id.ic_heart_watchlist -> { diff --git a/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml b/app/src/main/res/menu/detail_fragment_menu.xml similarity index 100% rename from app/src/main/res/menu/watchlist_favorite_detail_fragment.xml rename to app/src/main/res/menu/detail_fragment_menu.xml From 6b47776c0f29630846622b2bba48f639ce5f5b4b Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 14:34:26 -0300 Subject: [PATCH 20/41] Fix Watchlist unit tests --- .../details/usecase/DeleteFromWatchlistUseCaseTest.kt | 6 ++++++ .../tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt | 4 ++-- .../details/usecase/SaveTVShowInWatchlistUseCaseTest.kt | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt index a2be9039..988a7ab6 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt @@ -9,12 +9,14 @@ import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import com.intive.tmdbandroid.usecase.DeleteFromWatchlistUseCase import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runBlockingTest import org.junit.Assert import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.BDDMockito import org.mockito.Mock import org.mockito.junit.MockitoJUnitRunner import kotlin.time.ExperimentalTime @@ -62,6 +64,10 @@ class DeleteFromWatchlistUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTest() = mainCoroutineRule.runBlockingTest { + BDDMockito.given(watchlistRepository.delete(screening)).willReturn( + flowOf(false) + ) + val expected = deleteFromWatchlistUseCase(screening) expected.test { diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt index 46e799f2..e2d31be0 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt @@ -42,7 +42,7 @@ class GetIfExistsUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTestEmpty() = mainCoroutineRule.runBlockingTest { - BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(false) + BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(flowOf(false)) val expected = getIfExistsUseCase(2) @@ -56,7 +56,7 @@ class GetIfExistsUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTestNotEmpty() = mainCoroutineRule.runBlockingTest { - BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(true) + BDDMockito.given(watchlistRepository.exist(anyInt())).willReturn(flowOf(true)) val expected = getIfExistsUseCase(2) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt index 30ef5b62..a5f1f4cc 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt @@ -9,12 +9,14 @@ import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import com.intive.tmdbandroid.usecase.InsertInWatchlistUseCase import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runBlockingTest import org.junit.Assert import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.BDDMockito import org.mockito.Mock import org.mockito.junit.MockitoJUnitRunner import kotlin.time.ExperimentalTime @@ -62,6 +64,10 @@ class SaveTVShowInWatchlistUseCaseTest { @ExperimentalCoroutinesApi @ExperimentalTime fun invokeTest() = mainCoroutineRule.runBlockingTest { + BDDMockito.given(watchlistRepository.insert(screening)).willReturn( + flowOf(true) + ) + val expected = saveTVShowInWatchlistUseCase(screening) expected.test { From 31edf6ff3499e89720f3dcef5c1050d9095633a8 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 15:39:00 -0300 Subject: [PATCH 21/41] Resolve points 25 and 27 --- .../home/ui/adapters/WatchlistAdapter.kt | 14 ++- .../main/res/layout/item_horizontal_list.xml | 18 ---- app/src/main/res/layout/item_screening.xml | 96 ------------------- .../main/res/layout/item_screening_small.xml | 7 +- 4 files changed, 15 insertions(+), 120 deletions(-) delete mode 100644 app/src/main/res/layout/item_horizontal_list.xml delete mode 100644 app/src/main/res/layout/item_screening.xml diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt index b22575ba..36f3b478 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt @@ -1,6 +1,7 @@ package com.intive.tmdbandroid.home.ui.adapters import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter @@ -8,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R +import com.intive.tmdbandroid.databinding.ItemScreeningSmallBinding import com.intive.tmdbandroid.databinding.ItemScreeningWatchlistBinding import com.intive.tmdbandroid.model.Screening @@ -24,18 +26,22 @@ class WatchlistAdapter(private val clickListener: ((Screening) -> Unit)) : ListA } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchlistHolder = WatchlistHolder( - ItemScreeningWatchlistBinding.inflate(LayoutInflater.from(parent.context), parent, false), + ItemScreeningSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false), clickListener ) - class WatchlistHolder(binding: ItemScreeningWatchlistBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { - private val title = binding.titleItemWatchlist - private val backdrop = binding.backdropItemWatchlist + class WatchlistHolder(binding: ItemScreeningSmallBinding, private val clickListener: (Screening) -> Unit) : RecyclerView.ViewHolder(binding.root) { + private val title = binding.itemTitle + private val backdrop = binding.itemBackdrop + private val popularity = binding.popularityCard + private val releaseDate = binding.itemDate private val context = binding.root.context private val imgUrl = binding.root.resources.getString(R.string.base_imageURL) fun bind (item: Screening) { + popularity.visibility = View.GONE + releaseDate.visibility = View.GONE itemView.setOnClickListener { clickListener.invoke(item) } diff --git a/app/src/main/res/layout/item_horizontal_list.xml b/app/src/main/res/layout/item_horizontal_list.xml deleted file mode 100644 index 76c08f13..00000000 --- a/app/src/main/res/layout/item_horizontal_list.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_screening.xml b/app/src/main/res/layout/item_screening.xml deleted file mode 100644 index 98671d40..00000000 --- a/app/src/main/res/layout/item_screening.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_screening_small.xml b/app/src/main/res/layout/item_screening_small.xml index 8eac45a5..ddc980b2 100644 --- a/app/src/main/res/layout/item_screening_small.xml +++ b/app/src/main/res/layout/item_screening_small.xml @@ -12,7 +12,8 @@ + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/margin_short"> Date: Wed, 6 Oct 2021 15:41:11 -0300 Subject: [PATCH 22/41] Have layout_empty.xml, layout_error.xml and layout_progressbar.xml all behave the same way --- .../tmdbandroid/details/ui/DetailFragment.kt | 24 ++++++++-------- .../tmdbandroid/home/ui/MoviesFragment.kt | 6 ++-- .../tmdbandroid/home/ui/TVShowsFragment.kt | 6 ++-- .../tmdbandroid/home/ui/WatchlistFragment.kt | 6 ++-- .../tmdbandroid/search/ui/SearchFragment.kt | 16 +++++------ app/src/main/res/layout/fragment_detail.xml | 23 ++++++++------- app/src/main/res/layout/fragment_movies.xml | 28 ++++++++++++++----- app/src/main/res/layout/fragment_search.xml | 19 +++++++++++-- app/src/main/res/layout/fragment_tvshows.xml | 28 ++++++++++++++----- .../main/res/layout/fragment_watchlist.xml | 20 +++++++------ app/src/main/res/layout/layout_empty.xml | 5 ++-- app/src/main/res/layout/layout_error.xml | 17 +++++------ .../main/res/layout/layout_progressbar.xml | 15 ++++++---- 13 files changed, 130 insertions(+), 83 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index d68f85ac..d3a45659 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -104,18 +104,18 @@ class DetailFragment : Fragment() { viewModel.uiState.collect { state -> when (state) { is State.Success -> { - binding.layoutErrorDetail.errorContainer.visibility = View.GONE - binding.layoutLoadingDetail.progressBar.visibility = View.GONE + binding.layoutErrorDetail.root.visibility = View.GONE + binding.layoutLoadingDetail.root.visibility = View.GONE setupUI(binding, state.data) } is State.Error -> { - binding.layoutLoadingDetail.progressBar.visibility = View.GONE - binding.layoutErrorDetail.errorContainer.visibility = View.VISIBLE + binding.layoutLoadingDetail.root.visibility = View.GONE + binding.layoutErrorDetail.root.visibility = View.VISIBLE binding.coordinatorContainerDetail.visibility = View.VISIBLE } is State.Loading -> { - binding.layoutErrorDetail.errorContainer.visibility = View.GONE - binding.layoutLoadingDetail.progressBar.visibility = View.VISIBLE + binding.layoutErrorDetail.root.visibility = View.GONE + binding.layoutLoadingDetail.root.visibility = View.VISIBLE } else -> {} } @@ -128,19 +128,19 @@ class DetailFragment : Fragment() { viewModel.watchlistUIState.collectLatest { when (it) { is State.Success -> { - binding.layoutErrorDetail.errorContainer.visibility = View.GONE - binding.layoutLoadingDetail.progressBar.visibility = View.GONE + binding.layoutErrorDetail.root.visibility = View.GONE + binding.layoutLoadingDetail.root.visibility = View.GONE selectOrUnselectWatchlistFav(binding, it.data) isSaveOnWatchlist = it.data } State.Error -> { - binding.layoutLoadingDetail.progressBar.visibility = View.GONE - binding.layoutErrorDetail.errorContainer.visibility = View.VISIBLE + binding.layoutLoadingDetail.root.visibility = View.GONE + binding.layoutErrorDetail.root.visibility = View.VISIBLE binding.coordinatorContainerDetail.visibility = View.VISIBLE } State.Loading -> { - binding.layoutErrorDetail.errorContainer.visibility = View.GONE - binding.layoutLoadingDetail.progressBar.visibility = View.VISIBLE + binding.layoutErrorDetail.root.visibility = View.GONE + binding.layoutLoadingDetail.root.visibility = View.VISIBLE } else -> {} } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt index 8124c8df..199c1e70 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt @@ -78,17 +78,17 @@ class MoviesFragment : Fragment() { when (resultMovies) { is State.Success> -> { - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE moviePageAdapter.submitData(resultMovies.data) } is State.Error -> { binding.layoutProgressbar.root.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.VISIBLE + binding.layoutError.root.visibility = View.VISIBLE } is State.Loading -> { binding.layoutProgressbar.root.visibility = View.VISIBLE - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE } else -> throw RuntimeException(context?.getString(R.string.state_error)) } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt index 1b66410a..25d2e9e4 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt @@ -77,17 +77,17 @@ class TVShowsFragment : Fragment() { when (resultTVShows) { is State.Success> -> { - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE tvShowPageAdapter.submitData(resultTVShows.data) } is State.Error -> { binding.layoutProgressbar.root.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.VISIBLE + binding.layoutError.root.visibility = View.VISIBLE } is State.Loading -> { binding.layoutProgressbar.root.visibility = View.VISIBLE - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE } else -> throw RuntimeException(context?.getString(R.string.state_error)) } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt index 4ecc8e0c..5ded0035 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt @@ -71,7 +71,7 @@ class WatchlistFragment : Fragment() { viewModel.uiState.collectLatest { when(it) { is State.Success> -> { - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE binding.layoutProgressbar.root.visibility = View.GONE binding.layoutNodata.root.isVisible = it.data.isEmpty() @@ -80,11 +80,11 @@ class WatchlistFragment : Fragment() { } is State.Error -> { binding.layoutProgressbar.root.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.VISIBLE + binding.layoutError.root.visibility = View.VISIBLE } is State.Loading -> { binding.layoutProgressbar.root.visibility = View.VISIBLE - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE } else -> throw RuntimeException(context?.getString(R.string.state_error)) } diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt index 4098df72..19cab4e9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/SearchFragment.kt @@ -119,8 +119,8 @@ class SearchFragment : Fragment() { viewModel.uiState.collectLatest { screening -> when (screening) { is State.Success> -> { - binding.layoutProgressbar.progressBar.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutProgressbar.root.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE binding.layoutEmpty.root.visibility = View.GONE binding.layoutSearchHint.hintContainer.visibility = View.GONE binding.resultSearchHeader.text = @@ -131,20 +131,20 @@ class SearchFragment : Fragment() { searchAdapter.submitData(screening.data) } is State.Error -> { - binding.layoutProgressbar.progressBar.visibility = View.GONE + binding.layoutProgressbar.root.visibility = View.GONE binding.layoutEmpty.root.visibility = View.GONE binding.layoutSearchHint.hintContainer.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.VISIBLE + binding.layoutError.root.visibility = View.VISIBLE } is State.Loading -> { - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE binding.layoutEmpty.root.visibility = View.GONE binding.layoutSearchHint.hintContainer.visibility = View.GONE - binding.layoutProgressbar.progressBar.visibility = View.VISIBLE + binding.layoutProgressbar.root.visibility = View.VISIBLE } is State.Waiting -> { - binding.layoutProgressbar.progressBar.visibility = View.GONE - binding.layoutError.errorContainer.visibility = View.GONE + binding.layoutProgressbar.root.visibility = View.GONE + binding.layoutError.root.visibility = View.GONE binding.layoutEmpty.root.visibility = View.GONE binding.layoutSearchHint.hintContainer.visibility = View.VISIBLE } diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index 35a83440..a75e0246 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -16,8 +16,9 @@ + android:layout_height="350dp" + android:fitsSystemWindows="true" + android:theme="@style/ThemeOverlay.MaterialComponents.Dark"> @@ -253,20 +254,22 @@ - + android:layout_width="0dp" + android:layout_height="0dp" + android:visibility="gone" + app:layout_anchor="@+id/coordinatorContainer_detail" + app:layout_anchorGravity="center" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_movies.xml b/app/src/main/res/layout/fragment_movies.xml index f2df46f1..81cf230c 100644 --- a/app/src/main/res/layout/fragment_movies.xml +++ b/app/src/main/res/layout/fragment_movies.xml @@ -18,20 +18,34 @@ + + + app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index bf9efd95..557e89e4 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -109,10 +109,16 @@ app:layout_constraintTop_toBottomOf="@id/result_search_header" tools:listitem="@layout/item_found_search" /> - + layout="@layout/layout_error" + android:layout_width="0dp" + android:layout_height="0dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/result_search_header" /> + android:layout_width="0dp" + android:layout_height="0dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/result_search_header" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_tvshows.xml b/app/src/main/res/layout/fragment_tvshows.xml index 96c06d4d..2e8e3634 100644 --- a/app/src/main/res/layout/fragment_tvshows.xml +++ b/app/src/main/res/layout/fragment_tvshows.xml @@ -20,20 +20,34 @@ + app:layout_constraintTop_toTopOf="parent" /> - + + + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_watchlist.xml b/app/src/main/res/layout/fragment_watchlist.xml index 342ba24c..ff0f124e 100644 --- a/app/src/main/res/layout/fragment_watchlist.xml +++ b/app/src/main/res/layout/fragment_watchlist.xml @@ -20,29 +20,31 @@ + app:layout_constraintTop_toTopOf="parent" /> - @@ -20,12 +20,11 @@ android:id="@+id/message_empty_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="@dimen/margin_medium" android:text="@string/empty_message" android:textColor="@color/black" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/ic_warning_empty_imageView" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_error.xml b/app/src/main/res/layout/layout_error.xml index f6807533..291a81da 100644 --- a/app/src/main/res/layout/layout_error.xml +++ b/app/src/main/res/layout/layout_error.xml @@ -2,35 +2,32 @@ + android:background="@color/white"> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/error_image" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_progressbar.xml b/app/src/main/res/layout/layout_progressbar.xml index ad180912..1d38b6a1 100644 --- a/app/src/main/res/layout/layout_progressbar.xml +++ b/app/src/main/res/layout/layout_progressbar.xml @@ -1,13 +1,18 @@ - + android:layout_height="match_parent" + android:background="@color/white"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> - - \ No newline at end of file + \ No newline at end of file From 13480c55f32a732b57fd8639a133907c6f4c3497 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 6 Oct 2021 16:42:00 -0300 Subject: [PATCH 23/41] Resolve point 8 --- .../java/com/intive/tmdbandroid/details/ui/DetailFragment.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index d3a45659..87caea98 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -135,8 +135,7 @@ class DetailFragment : Fragment() { } State.Error -> { binding.layoutLoadingDetail.root.visibility = View.GONE - binding.layoutErrorDetail.root.visibility = View.VISIBLE - binding.coordinatorContainerDetail.visibility = View.VISIBLE + Toast.makeText(context, "Couldn't save to watchlist. Please try later", Toast.LENGTH_LONG).show() } State.Loading -> { binding.layoutErrorDetail.root.visibility = View.GONE From 11ebc3a383d30ab1e6176595c6c5b27bcc3dd7f0 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Thu, 7 Oct 2021 14:43:14 -0300 Subject: [PATCH 24/41] Resolve points 9 and 35 --- .../datasource/local/LocalStorageTest.kt | 2 +- .../tmdbandroid/datasource/local/Dao.kt | 2 +- .../datasource/local/LocalStorage.kt | 2 +- .../datasource/network/ApiClient.kt | 6 +++++- .../tmdbandroid/datasource/network/Service.kt | 8 ++++---- .../tmdbandroid/details/ui/DetailFragment.kt | 19 +++++++++++-------- .../details/viewmodel/DetailsViewModel.kt | 17 ++++++++++++++++- .../entity/{ => movie}/MovieListItemEntity.kt | 2 +- .../entity/{ => movie}/ResultMoviesEntity.kt | 2 +- .../{ => network}/ResultTVShowOrMovie.kt | 2 +- .../entity/{ => person}/ResultPeopleEntity.kt | 2 +- .../entity/{ => room}/ScreeningORMEntity.kt | 2 +- .../{ => tvshow}/ResultTVShowsEntity.kt | 2 +- .../{ => tvshow}/TVShowListItemEntity.kt | 2 +- .../entity/{ => video}/VideoEntity.kt | 2 +- .../entity/{ => video}/VideoListItemEntity.kt | 2 +- .../tmdbandroid/home/ui/MoviesFragment.kt | 3 +-- .../tmdbandroid/home/ui/TVShowsFragment.kt | 3 +-- .../tmdbandroid/home/ui/WatchlistFragment.kt | 3 +-- .../home/viewmodel/MoviesViewModel.kt | 10 +++++----- .../home/viewmodel/TVShowsViewModel.kt | 10 +++++----- .../home/viewmodel/WatchlistViewModel.kt | 10 +++++----- .../com/intive/tmdbandroid/model/Screening.kt | 2 +- .../main/res/menu/detail_fragment_menu.xml | 5 ++--- 24 files changed, 69 insertions(+), 51 deletions(-) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => movie}/MovieListItemEntity.kt (94%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => movie}/ResultMoviesEntity.kt (91%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => network}/ResultTVShowOrMovie.kt (96%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => person}/ResultPeopleEntity.kt (85%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => room}/ScreeningORMEntity.kt (97%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => tvshow}/ResultTVShowsEntity.kt (91%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => tvshow}/TVShowListItemEntity.kt (94%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => video}/VideoEntity.kt (66%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => video}/VideoListItemEntity.kt (74%) diff --git a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt index 94414bba..5eef57bf 100644 --- a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt +++ b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt @@ -4,7 +4,7 @@ import android.content.Context import androidx.room.Room import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity import com.intive.tmdbandroid.model.Genre import com.intive.tmdbandroid.model.Network import junit.framework.TestCase diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt index a35f1968..1c4fe05c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt @@ -2,7 +2,7 @@ package com.intive.tmdbandroid.datasource.local import androidx.room.* import androidx.room.Dao -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity @Dao interface Dao{ diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt index 82bd9e10..44197934 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt @@ -3,7 +3,7 @@ package com.intive.tmdbandroid.datasource.local import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity import com.intive.tmdbandroid.model.converter.GenreConverter import com.intive.tmdbandroid.model.converter.IntConverter import com.intive.tmdbandroid.model.converter.NetworkConverter diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt index 2e1b2688..47c5908c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt @@ -1,6 +1,10 @@ package com.intive.tmdbandroid.datasource.network -import com.intive.tmdbandroid.entity.* +import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies +import com.intive.tmdbandroid.entity.person.ResultPeopleEntity +import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity +import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity +import com.intive.tmdbandroid.entity.video.VideoEntity import com.intive.tmdbandroid.model.Movie import com.intive.tmdbandroid.model.TVShow import retrofit2.http.GET diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt index ddae202d..b35bd9b9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt @@ -2,10 +2,10 @@ package com.intive.tmdbandroid.datasource.network import com.intive.tmdbandroid.BuildConfig import com.intive.tmdbandroid.common.RetrofitHelper -import com.intive.tmdbandroid.entity.ResultListTVShowOrMovies -import com.intive.tmdbandroid.entity.ResultMoviesEntity -import com.intive.tmdbandroid.entity.ResultPeopleEntity -import com.intive.tmdbandroid.entity.ResultTVShowsEntity +import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies +import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity +import com.intive.tmdbandroid.entity.person.ResultPeopleEntity +import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity import com.intive.tmdbandroid.model.Movie import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.model.TVShow diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt index 87caea98..0a69c160 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/DetailFragment.kt @@ -66,10 +66,12 @@ class DetailFragment : Fragment() { ): View { val binding = FragmentDetailBinding.inflate(inflater, container, false) - collectScreeningDetailFromViewModel(binding) - collectWatchlistDataFromViewModel(binding) - collectTrailer() - collectRecommendations(binding) + if(savedInstanceState == null){ + collectScreeningDetailFromViewModel(binding) + collectWatchlistDataFromViewModel(binding) + collectTrailer() + collectRecommendations(binding) + } initViews(binding) @@ -113,11 +115,10 @@ class DetailFragment : Fragment() { binding.layoutErrorDetail.root.visibility = View.VISIBLE binding.coordinatorContainerDetail.visibility = View.VISIBLE } - is State.Loading -> { + else -> { binding.layoutErrorDetail.root.visibility = View.GONE binding.layoutLoadingDetail.root.visibility = View.VISIBLE } - else -> {} } } } @@ -137,11 +138,10 @@ class DetailFragment : Fragment() { binding.layoutLoadingDetail.root.visibility = View.GONE Toast.makeText(context, "Couldn't save to watchlist. Please try later", Toast.LENGTH_LONG).show() } - State.Loading -> { + else -> { binding.layoutErrorDetail.root.visibility = View.GONE binding.layoutLoadingDetail.root.visibility = View.VISIBLE } - else -> {} } } } @@ -159,6 +159,9 @@ class DetailFragment : Fragment() { showDialog(it.data) } } + is State.Loading -> { + Toast.makeText(context, "Loading trailer...", Toast.LENGTH_LONG).show() + } else -> { Toast.makeText(context, "There was an error. Please try again", Toast.LENGTH_LONG).show() } diff --git a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt index b07b3a05..631bfae9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt @@ -27,7 +27,7 @@ class DetailsViewModel @Inject internal constructor( private val _state = MutableStateFlow>(State.Waiting) val uiState: StateFlow> = _state - private val _watchlistState = MutableStateFlow>(State.Loading) + private val _watchlistState = MutableStateFlow>(State.Waiting) val watchlistUIState: StateFlow> = _watchlistState private val _trailerState = Channel>() @@ -51,6 +51,9 @@ class DetailsViewModel @Inject internal constructor( fun getTVShowTrailer(id: Int) { viewModelScope.launch { tvShowTrailerUseCase(id) + .onStart { + _trailerState.send(State.Loading) + } .catch { _trailerState.send(State.Error) } @@ -75,6 +78,9 @@ class DetailsViewModel @Inject internal constructor( fun getMovieTrailer(id: Int) { viewModelScope.launch { movieTrailerUseCase(id) + .onStart { + _trailerState.send(State.Loading) + } .catch { _trailerState.send(State.Error) } @@ -87,6 +93,9 @@ class DetailsViewModel @Inject internal constructor( fun addToWatchlist(screening: Screening) { viewModelScope.launch { insertInWatchlistUseCase(screening) + .onStart { + _watchlistState.value = State.Loading + } .catch { _watchlistState.value = State.Error } @@ -99,6 +108,9 @@ class DetailsViewModel @Inject internal constructor( fun deleteFromWatchlist(screening: Screening) { viewModelScope.launch { deleteFromWatchlistUseCase(screening) + .onStart { + _watchlistState.value = State.Loading + } .catch { _watchlistState.value = State.Error } @@ -111,6 +123,9 @@ class DetailsViewModel @Inject internal constructor( fun existAsFavorite(id: Int) { viewModelScope.launch { existUseCase(id) + .onStart { + _watchlistState.value = State.Loading + } .catch { _watchlistState.value = State.Error } diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt similarity index 94% rename from app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt index 99fbb7c2..83c97757 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/MovieListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.movie import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultMoviesEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt similarity index 91% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultMoviesEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt index 3056f1be..6d56d37d 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultMoviesEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.movie import com.google.gson.annotations.SerializedName import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt similarity index 96% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt index 897359c7..52426a95 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowOrMovie.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.network import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultPeopleEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt similarity index 85% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultPeopleEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt index 8a77b4aa..c91f4ce2 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultPeopleEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.person data class ResultPeopleEntity( val page: Int, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/room/ScreeningORMEntity.kt similarity index 97% rename from app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/room/ScreeningORMEntity.kt index 59669e78..9fc20865 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ScreeningORMEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/room/ScreeningORMEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.room import androidx.room.Entity import androidx.room.PrimaryKey diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowsEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/ResultTVShowsEntity.kt similarity index 91% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowsEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/tvshow/ResultTVShowsEntity.kt index 5ad01963..4ed2062b 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultTVShowsEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/ResultTVShowsEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.tvshow import com.google.gson.annotations.SerializedName import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt similarity index 94% rename from app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt index c991080a..349bac5a 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/TVShowListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.tvshow import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/VideoEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/video/VideoEntity.kt similarity index 66% rename from app/src/main/java/com/intive/tmdbandroid/entity/VideoEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/video/VideoEntity.kt index 4cb688fd..f96c6a1c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/VideoEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/video/VideoEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.video data class VideoEntity( val id: Int, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/VideoListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/video/VideoListItemEntity.kt similarity index 74% rename from app/src/main/java/com/intive/tmdbandroid/entity/VideoListItemEntity.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/video/VideoListItemEntity.kt index 178ad8cb..564df9e1 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/VideoListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/video/VideoListItemEntity.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.video data class VideoListItemEntity( val key: String, diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt index 199c1e70..61c93ee7 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/MoviesFragment.kt @@ -86,11 +86,10 @@ class MoviesFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.GONE binding.layoutError.root.visibility = View.VISIBLE } - is State.Loading -> { + else -> { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.root.visibility = View.GONE } - else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt index 25d2e9e4..ff662ed3 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/TVShowsFragment.kt @@ -85,11 +85,10 @@ class TVShowsFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.GONE binding.layoutError.root.visibility = View.VISIBLE } - is State.Loading -> { + else -> { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.root.visibility = View.GONE } - else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt index 5ded0035..3b707b06 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/WatchlistFragment.kt @@ -82,11 +82,10 @@ class WatchlistFragment : Fragment() { binding.layoutProgressbar.root.visibility = View.GONE binding.layoutError.root.visibility = View.VISIBLE } - is State.Loading -> { + else -> { binding.layoutProgressbar.root.visibility = View.VISIBLE binding.layoutError.root.visibility = View.GONE } - else -> throw RuntimeException(context?.getString(R.string.state_error)) } } } diff --git a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModel.kt index 79f6218d..a48a84e9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/MoviesViewModel.kt @@ -8,10 +8,7 @@ import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.usecase.PaginatedPopularMoviesUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import javax.inject.Inject @@ -20,12 +17,15 @@ class MoviesViewModel @Inject internal constructor( private val paginatedPopularMoviesUseCase: PaginatedPopularMoviesUseCase ) : ViewModel() { - private val _state = MutableStateFlow>>(State.Loading) + private val _state = MutableStateFlow>>(State.Waiting) val uiState: StateFlow>> = _state fun popularMovies() { viewModelScope.launch { paginatedPopularMoviesUseCase() + .onStart { + _state.value = State.Loading + } .cachedIn(viewModelScope) .catch { _state.value = State.Error diff --git a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModel.kt index e092342e..7106c9d3 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModel.kt @@ -8,10 +8,7 @@ import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.usecase.PaginatedPopularTVShowsUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import javax.inject.Inject @@ -20,12 +17,15 @@ class TVShowsViewModel @Inject internal constructor( private val paginatedPopularTVShowsUseCase: PaginatedPopularTVShowsUseCase ) : ViewModel() { - private val _state = MutableStateFlow>>(State.Loading) + private val _state = MutableStateFlow>>(State.Waiting) val uiState: StateFlow>> = _state fun popularTVShows() { viewModelScope.launch { paginatedPopularTVShowsUseCase() + .onStart { + _state.value = State.Loading + } .cachedIn(viewModelScope) .catch { _state.value = State.Error diff --git a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt index 8ad9af2a..4b0c89bd 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModel.kt @@ -6,10 +6,7 @@ import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.usecase.GetAllItemsInWatchlistUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import javax.inject.Inject @@ -18,12 +15,15 @@ class WatchlistViewModel @Inject internal constructor( private val getAllItemsInWatchlistUseCase: GetAllItemsInWatchlistUseCase ) : ViewModel() { - private val _state = MutableStateFlow>>(State.Loading) + private val _state = MutableStateFlow>>(State.Waiting) val uiState: StateFlow>> = _state fun watchlistScreening() { viewModelScope.launch { getAllItemsInWatchlistUseCase() + .onStart { + _state.value = State.Loading + } .catch { _state.value = State.Error } diff --git a/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt b/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt index 2b88a9f2..4b98d649 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/Screening.kt @@ -1,6 +1,6 @@ package com.intive.tmdbandroid.model -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity data class Screening( val backdrop_path: String?, diff --git a/app/src/main/res/menu/detail_fragment_menu.xml b/app/src/main/res/menu/detail_fragment_menu.xml index 8c2073c4..f8c08c8a 100644 --- a/app/src/main/res/menu/detail_fragment_menu.xml +++ b/app/src/main/res/menu/detail_fragment_menu.xml @@ -1,9 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> - From b68500cfb26b3f733dcff382c24e00756e5f6c4a Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Tue, 12 Oct 2021 15:49:52 -0300 Subject: [PATCH 25/41] Merge with master --- .../tmdbandroid/datasource/network/ApiClient.kt | 2 ++ .../tmdbandroid/datasource/network/Service.kt | 1 + .../details/ui/person/ui/DetailPersonFragment.kt | 2 +- .../ui/person/viewmodel/DetailPersonViewModel.kt | 2 +- .../entity/{ => network}/ResultCombinedCredits.kt | 3 +-- .../entity/person/ResultPeopleEntity.kt | 1 - .../entity/{ => person}/ResultPerson.kt | 2 +- .../tmdbandroid/repository/CatalogRepository.kt | 2 +- .../usecase/person/GetDetailPersonUseCase.kt | 2 +- app/src/main/res/layout/fragment_detail_person.xml | 14 ++++++++------ ....xml => watchlist_favorite_detail_fragment.xml} | 0 11 files changed, 17 insertions(+), 14 deletions(-) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => network}/ResultCombinedCredits.kt (92%) rename app/src/main/java/com/intive/tmdbandroid/entity/{ => person}/ResultPerson.kt (75%) rename app/src/main/res/menu/{detail_fragment_menu.xml => watchlist_favorite_detail_fragment.xml} (100%) diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt index dc9776c6..1074c522 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt @@ -1,7 +1,9 @@ package com.intive.tmdbandroid.datasource.network import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies +import com.intive.tmdbandroid.entity.network.ResultCombinedCredits import com.intive.tmdbandroid.entity.person.ResultPeopleEntity +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity import com.intive.tmdbandroid.entity.video.VideoEntity diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt index 3cac92fc..dc3d4ac2 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt @@ -5,6 +5,7 @@ import com.intive.tmdbandroid.common.RetrofitHelper import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity import com.intive.tmdbandroid.entity.person.ResultPeopleEntity +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity import com.intive.tmdbandroid.model.Movie import com.intive.tmdbandroid.model.Screening diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/ui/DetailPersonFragment.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/ui/DetailPersonFragment.kt index 68b2dcf1..70cf390f 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/ui/DetailPersonFragment.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/ui/DetailPersonFragment.kt @@ -22,7 +22,7 @@ import com.intive.tmdbandroid.common.State import com.intive.tmdbandroid.databinding.FragmentDetailPersonBinding import com.intive.tmdbandroid.details.ui.person.adapter.CombinedCreditsAdapter import com.intive.tmdbandroid.details.ui.person.viewmodel.DetailPersonViewModel -import com.intive.tmdbandroid.entity.ResultPerson +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.model.Screening import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/viewmodel/DetailPersonViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/viewmodel/DetailPersonViewModel.kt index d5cbf367..9b445d9c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/viewmodel/DetailPersonViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/viewmodel/DetailPersonViewModel.kt @@ -3,7 +3,7 @@ package com.intive.tmdbandroid.details.ui.person.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.intive.tmdbandroid.common.State -import com.intive.tmdbandroid.entity.ResultPerson +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.usecase.person.GetCombinedCreditsUseCase import com.intive.tmdbandroid.usecase.person.GetDetailPersonUseCase diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultCombinedCredits.kt b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultCombinedCredits.kt similarity index 92% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultCombinedCredits.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/network/ResultCombinedCredits.kt index 22fecafc..be12e157 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultCombinedCredits.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultCombinedCredits.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.network import com.intive.tmdbandroid.model.Screening @@ -25,7 +25,6 @@ data class CastItem( poster_path = null, status = null, vote_average = 0.0, - vote_count = 0, popularity = 0.0, release_date = null, media_type, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt index 246be681..af6a2892 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPeopleEntity.kt @@ -27,7 +27,6 @@ data class PersonItemEntity( poster_path = profile_path, status = null, vote_average = 0.0, - vote_count = 0, popularity, release_date = null, media_type = "person", diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/ResultPerson.kt b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPerson.kt similarity index 75% rename from app/src/main/java/com/intive/tmdbandroid/entity/ResultPerson.kt rename to app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPerson.kt index b8760c42..316494f0 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/ResultPerson.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/person/ResultPerson.kt @@ -1,4 +1,4 @@ -package com.intive.tmdbandroid.entity +package com.intive.tmdbandroid.entity.person data class ResultPerson( val name: String, diff --git a/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt b/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt index 7815c6be..4aa32250 100644 --- a/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt +++ b/app/src/main/java/com/intive/tmdbandroid/repository/CatalogRepository.kt @@ -6,7 +6,7 @@ import androidx.paging.PagingData import com.intive.tmdbandroid.datasource.ScreeningPagingSource import com.intive.tmdbandroid.datasource.ScreeningSearchSource import com.intive.tmdbandroid.datasource.network.Service -import com.intive.tmdbandroid.entity.ResultPerson +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.model.Movie import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.model.TVShow diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/person/GetDetailPersonUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/person/GetDetailPersonUseCase.kt index e62d9671..53962e6c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/person/GetDetailPersonUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/person/GetDetailPersonUseCase.kt @@ -1,6 +1,6 @@ package com.intive.tmdbandroid.usecase.person -import com.intive.tmdbandroid.entity.ResultPerson +import com.intive.tmdbandroid.entity.person.ResultPerson import com.intive.tmdbandroid.repository.CatalogRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/app/src/main/res/layout/fragment_detail_person.xml b/app/src/main/res/layout/fragment_detail_person.xml index bfe35ad0..e1922b37 100644 --- a/app/src/main/res/layout/fragment_detail_person.xml +++ b/app/src/main/res/layout/fragment_detail_person.xml @@ -129,20 +129,22 @@ - + android:layout_width="0dp" + android:layout_height="0dp" + android:visibility="gone" + app:layout_anchor="@+id/coordinatorContainer_detail" + app:layout_anchorGravity="center" /> - \ No newline at end of file diff --git a/app/src/main/res/menu/detail_fragment_menu.xml b/app/src/main/res/menu/watchlist_favorite_detail_fragment.xml similarity index 100% rename from app/src/main/res/menu/detail_fragment_menu.xml rename to app/src/main/res/menu/watchlist_favorite_detail_fragment.xml From 1b803306b8c8c59c8351bc35c97050935f1706f4 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Tue, 12 Oct 2021 15:56:07 -0300 Subject: [PATCH 26/41] Remove unused import and hardcoded dimensions --- .../tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt | 1 - app/src/main/res/layout/fragment_detail.xml | 2 +- app/src/main/res/layout/layout_search_hint.xml | 4 ++-- app/src/main/res/values/dimens.xml | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt index 317a2b5f..5f22b368 100644 --- a/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt +++ b/app/src/main/java/com/intive/tmdbandroid/usecase/GetAllItemsInWatchlistUseCase.kt @@ -3,7 +3,6 @@ package com.intive.tmdbandroid.usecase import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOf import javax.inject.Inject class GetAllItemsInWatchlistUseCase @Inject constructor(private val watchlistRepository: WatchlistRepository) { diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index a75e0246..cc880883 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -16,7 +16,7 @@ diff --git a/app/src/main/res/layout/layout_search_hint.xml b/app/src/main/res/layout/layout_search_hint.xml index 249a7347..b6730e45 100644 --- a/app/src/main/res/layout/layout_search_hint.xml +++ b/app/src/main/res/layout/layout_search_hint.xml @@ -9,8 +9,8 @@ 12sp 4dp 2dp + 350dp + 100dp \ No newline at end of file From 740db91cc6e82d9afb9952b0b512e2fd34ef3a56 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 13 Oct 2021 13:00:48 -0300 Subject: [PATCH 27/41] Remove white background from layout_progressbar.xml --- app/src/main/res/layout/layout_progressbar.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/layout_progressbar.xml b/app/src/main/res/layout/layout_progressbar.xml index 1d38b6a1..67c8b461 100644 --- a/app/src/main/res/layout/layout_progressbar.xml +++ b/app/src/main/res/layout/layout_progressbar.xml @@ -4,7 +4,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/white"> + style="@style/Platform.MaterialComponents"> Date: Wed, 13 Oct 2021 13:04:46 -0300 Subject: [PATCH 28/41] Change biography header and content colors to adapt to dark mode --- app/src/main/res/layout/fragment_detail_person.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/fragment_detail_person.xml b/app/src/main/res/layout/fragment_detail_person.xml index 041e4444..dc21a7eb 100644 --- a/app/src/main/res/layout/fragment_detail_person.xml +++ b/app/src/main/res/layout/fragment_detail_person.xml @@ -71,7 +71,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/biography" - android:textColor="@color/black" + android:textColor="@color/material_on_background_emphasis_high_type" android:textSize="20sp" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" @@ -83,7 +83,7 @@ android:layout_marginVertical="20dp" android:layout_marginTop="8dp" android:lineSpacingExtra="4dp" - android:textColor="@color/black" + android:textColor="@color/material_on_background_emphasis_high_type" android:textSize="16sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/biography_textView" From aec9c65febcb6667a6ce3d62aaec3c6617f98108 Mon Sep 17 00:00:00 2001 From: Francisco Beccuti Date: Wed, 13 Oct 2021 16:04:35 -0300 Subject: [PATCH 29/41] merge with master. --- .../datasource/local/LocalStorageTest.kt | 8 ++++++-- .../com/intive/tmdbandroid/datasource/local/Dao.kt | 2 +- .../tmdbandroid/datasource/local/LocalStorage.kt | 2 +- .../details/ui/adapters/NetworkAdapter.kt | 1 - .../details/viewmodel/DetailsViewModel.kt | 4 ++-- .../entity/movie/MovieListItemEntity.kt | 3 --- .../tmdbandroid/entity/movie/ResultMoviesEntity.kt | 1 + .../entity/network/ResultTVShowOrMovie.kt | 2 -- .../entity/tvshow/TVShowListItemEntity.kt | 1 - .../java/com/intive/tmdbandroid/model/Movie.kt | 3 --- .../java/com/intive/tmdbandroid/model/TVShow.kt | 4 ---- .../usecase/DeleteFromWatchlistUseCaseTest.kt | 3 +-- .../details/usecase/GetIfExistsUseCaseTest.kt | 3 +-- .../details/usecase/GetMovieSimilarUseCaseTest.kt | 3 +-- .../details/usecase/GetTVShowSimilarUseCaseTest.kt | 3 +-- .../usecase/SaveTVShowInWatchlistUseCaseTest.kt | 5 +++-- .../details/viewmodel/DetailsViewModelTest.kt | 14 ++++---------- .../home/viewmodel/TVShowsViewModelTest.kt | 6 ++---- .../home/viewmodel/WatchlistViewModelTest.kt | 3 +-- .../search/viewmodel/SearchViewModelTest.kt | 3 +-- .../tmdbandroid/usecase/DetailTVShowUseCaseTest.kt | 4 +--- .../usecase/PaginatedPopularTVShowsUseCaseTest.kt | 3 +-- .../tmdbandroid/usecase/SearchTVShowUseCaseTest.kt | 3 +-- 23 files changed, 29 insertions(+), 55 deletions(-) diff --git a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt index 5eef57bf..1076167c 100644 --- a/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt +++ b/app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt @@ -38,7 +38,9 @@ class LocalStorageTest : TestCase() { adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg")) + networks = listOf(Network("/netflixlogo.jpg")), + my_rate = 3.5, + my_favorite = true ) private val screeningUpdate = ScreeningORMEntity( @@ -58,7 +60,9 @@ class LocalStorageTest : TestCase() { adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg")) + networks = listOf(Network("/netflixlogo.jpg")), + my_rate = 3.5, + my_favorite = true ) // Override function setUp() and annotate it with @Before diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt index 216bcd5a..5707b6f6 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt @@ -2,7 +2,7 @@ package com.intive.tmdbandroid.datasource.local import androidx.room.* import androidx.room.Dao -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity import com.intive.tmdbandroid.entity.SessionORMEntity @Dao diff --git a/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt b/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt index 3ebaf7fa..624a2e17 100644 --- a/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt +++ b/app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt @@ -3,7 +3,7 @@ package com.intive.tmdbandroid.datasource.local import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters -import com.intive.tmdbandroid.entity.ScreeningORMEntity +import com.intive.tmdbandroid.entity.room.ScreeningORMEntity import com.intive.tmdbandroid.entity.SessionORMEntity import com.intive.tmdbandroid.model.converter.GenreConverter import com.intive.tmdbandroid.model.converter.IntConverter diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/NetworkAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/NetworkAdapter.kt index 9bef966e..03e6656c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/NetworkAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/NetworkAdapter.kt @@ -5,7 +5,6 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import androidx.swiperefreshlayout.widget.CircularProgressDrawable import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.intive.tmdbandroid.R diff --git a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt index 2bf8cc9c..a01fcc95 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModel.kt @@ -18,10 +18,10 @@ class DetailsViewModel @Inject internal constructor( private val movieUseCase: DetailMovieUseCase, private val insertInWatchlistUseCase: InsertInWatchlistUseCase, private val existUseCase: ExistUseCase, - private val tvShowTrailerUseCase: GetTVShowTrailer, + private val tvShowTrailerUseCase: GetTVShowTrailerUseCase, private val getTVShowSimilarUseCase: GetTVShowSimilarUseCase, private val getMovieSimilarUseCase: GetMovieSimilarUseCase, - private val movieTrailerUseCase: GetMovieTrailer, + private val movieTrailerUseCase: GetMovieTrailerUseCase, private val ratingMovieUseCase: RatingMovieUseCase, private val ratingTVShowUseCase: RatingTVShowUseCase, private val guestSessionUseCase: GuestSessionUseCase, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt index 1eb8fed2..716182c0 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/movie/MovieListItemEntity.kt @@ -7,12 +7,10 @@ data class MovieListItemEntity( val release_date: String?, val id: Int, val title: String, - val original_title: String, val overview: String, val popularity: Double?, val poster_path: String?, val vote_average: Double, - val vote_count: Int, val my_rate: Double, val my_favorite: Boolean ) { @@ -28,7 +26,6 @@ data class MovieListItemEntity( poster_path, null, vote_average, - vote_count, popularity ?: 0.0, release_date, "movie", diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt index 6d56d37d..cd8ec679 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/movie/ResultMoviesEntity.kt @@ -1,6 +1,7 @@ package com.intive.tmdbandroid.entity.movie import com.google.gson.annotations.SerializedName +import com.intive.tmdbandroid.entity.MovieListItemEntity import com.intive.tmdbandroid.model.Screening data class ResultMoviesEntity( diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt index 9d5e7a33..8b0087ce 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/network/ResultTVShowOrMovie.kt @@ -20,11 +20,9 @@ data class ResultTVShowOrMovie( val title: String, val video: Boolean, val vote_average: Double, - val vote_count: Int, val backdrop_path: String?, val first_air_date: String?, val name: String?, - val original_name: String?, val poster_path: String?, val my_rate: Double, val my_favorite: Boolean, diff --git a/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt index c10ebaa4..37179b9c 100644 --- a/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt +++ b/app/src/main/java/com/intive/tmdbandroid/entity/tvshow/TVShowListItemEntity.kt @@ -11,7 +11,6 @@ data class TVShowListItemEntity( val popularity: Double?, val poster_path: String?, val vote_average: Double, - val vote_count: Int, val my_rate: Double, val my_favorite: Boolean ) { diff --git a/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt b/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt index 46bc9f1d..0c282033 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/Movie.kt @@ -4,14 +4,12 @@ data class Movie( val backdrop_path: String, val genres: List, val id: Int, - val original_title: String, val overview: String, val popularity: Double, val poster_path: String, val release_date: String?, val title: String, val vote_average: Double, - val vote_count: Int, val status: String, val my_rate: Double, val my_favorite: Boolean @@ -28,7 +26,6 @@ data class Movie( poster_path, status, vote_average, - vote_count, popularity, release_date, media_type = "movie", diff --git a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt index 8a85621e..e27f3cac 100644 --- a/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt +++ b/app/src/main/java/com/intive/tmdbandroid/model/TVShow.kt @@ -2,7 +2,6 @@ package com.intive.tmdbandroid.model data class TVShow( val backdrop_path: String?, - val created_by: List, val first_air_date: String?, val genres: List, val id: Int, @@ -10,12 +9,10 @@ data class TVShow( val name: String, val number_of_episodes: Int?, val number_of_seasons: Int?, - val original_name: String, val overview: String, val poster_path: String?, val status: String?, val vote_average: Double, - val vote_count: Int, val networks: List, val my_rate:Double, val my_favorite: Boolean @@ -32,7 +29,6 @@ data class TVShow( poster_path, status, vote_average, - vote_count, popularity = 0.0, release_date = first_air_date, media_type = "tv", diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt index 7705057c..8c479eba 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/DeleteFromWatchlistUseCaseTest.kt @@ -43,13 +43,12 @@ class DeleteFromWatchlistUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt index 6a49cb44..40415d10 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetIfExistsUseCaseTest.kt @@ -44,13 +44,12 @@ class GetIfExistsUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetMovieSimilarUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetMovieSimilarUseCaseTest.kt index a6db381f..ad87d3ad 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetMovieSimilarUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetMovieSimilarUseCaseTest.kt @@ -45,13 +45,12 @@ class GetMovieSimilarUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetTVShowSimilarUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetTVShowSimilarUseCaseTest.kt index 5973610e..13b07503 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetTVShowSimilarUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/GetTVShowSimilarUseCaseTest.kt @@ -45,13 +45,12 @@ class GetTVShowSimilarUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt index b836a44c..3a364591 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/usecase/SaveTVShowInWatchlistUseCaseTest.kt @@ -9,12 +9,14 @@ import com.intive.tmdbandroid.model.Screening import com.intive.tmdbandroid.repository.WatchlistRepository import com.intive.tmdbandroid.usecase.InsertInWatchlistUseCase import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runBlockingTest import org.junit.Assert import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.BDDMockito import org.mockito.Mock import org.mockito.junit.MockitoJUnitRunner import kotlin.time.ExperimentalTime @@ -41,13 +43,12 @@ class SaveTVShowInWatchlistUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt index 5eb1a0a0..a0b517c5 100644 --- a/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/details/viewmodel/DetailsViewModelTest.kt @@ -38,17 +38,14 @@ class DetailsViewModelTest { genres = listOf(Genre(1, "genre1"), Genre(2, "genre2")), id = 1, name = "Simona la Cacarisa", - original_name = "El cochiloco", overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, - created_by = emptyList(), last_air_date = "1990-09-25", number_of_episodes = 5, number_of_seasons = 2, status = "Online", - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) @@ -59,11 +56,9 @@ class DetailsViewModelTest { genres = listOf(Genre(1, "genre1"), Genre(2, "genre2")), id = 1, title = "Simona la Cacarisa", - original_title = "El cochiloco", overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, status = "Online", popularity = 34.0, my_rate = 3.5, @@ -82,13 +77,12 @@ class DetailsViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) @@ -111,9 +105,9 @@ class DetailsViewModelTest { @Mock private lateinit var guestSessionUseCase: GuestSessionUseCase @Mock - private lateinit var tvShowTrailerUseCase: GetTVShowTrailer + private lateinit var tvShowTrailerUseCase: GetTVShowTrailerUseCase @Mock - private lateinit var movieTrailerUseCase: GetMovieTrailer + private lateinit var movieTrailerUseCase: GetMovieTrailerUseCase @Mock private lateinit var getTVShowSimilarUseCase: GetTVShowSimilarUseCase @Mock diff --git a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt index f2f6b237..c2ede246 100644 --- a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/TVShowsViewModelTest.kt @@ -55,13 +55,12 @@ class TVShowsViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ), @@ -77,13 +76,12 @@ class TVShowsViewModelTest { poster_path = "POSTER_PATH_2", status = "Online", vote_average = 15.5, - vote_count = 100, popularity = 80.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt index b5e2a4e7..52b40877 100644 --- a/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/home/viewmodel/WatchlistViewModelTest.kt @@ -40,13 +40,12 @@ class WatchlistViewModelTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt b/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt index 06f2b207..a183c569 100644 --- a/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/search/viewmodel/SearchViewModelTest.kt @@ -44,13 +44,12 @@ class SearchViewModelTest{ poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt index db0183c2..d93c32c6 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/DetailTVShowUseCaseTest.kt @@ -32,17 +32,15 @@ class DetailTVShowUseCaseTest{ genres = listOf(Genre(1, "genre1"), Genre(2,"genre2")), id = 1, name = "Simona la Cacarisa", - original_name = "El cochiloco", overview = "Simona la cacarisa, el cochiloco", poster_path = "POSTER_PATH", vote_average = 10.5, - vote_count = 100, created_by = emptyList(), last_air_date = "1990-09-25", number_of_episodes = 5, number_of_seasons = 2, status = "Online", - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt index 5c2792b4..b6d603fe 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/PaginatedPopularTVShowsUseCaseTest.kt @@ -41,13 +41,12 @@ class PaginatedPopularTVShowsUseCaseTest{ poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) diff --git a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt index 7af2937d..2cd4d977 100644 --- a/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt +++ b/app/src/test/java/com/intive/tmdbandroid/usecase/SearchTVShowUseCaseTest.kt @@ -41,13 +41,12 @@ class SearchTVShowUseCaseTest { poster_path = "POSTER_PATH", status = "Online", vote_average = 10.5, - vote_count = 100, popularity = 34.0, media_type = "tv", adult = false, genre_ids = null, video = false, - networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG")), + networks = listOf(Network("/netflixlogo.jpg")), my_rate = 3.5, my_favorite = true ) From 720605dfed9b7f69e5a46f32b3372f5cf094f804 Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 13 Oct 2021 17:02:50 -0300 Subject: [PATCH 30/41] Change colors of CircularProgressDrawable to be visible in dark mode. --- .../tmdbandroid/details/ui/adapters/RecommendationAdapter.kt | 2 ++ .../details/ui/person/adapter/CombinedCreditsAdapter.kt | 2 ++ .../intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt | 1 + .../com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt | 2 ++ .../tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt | 2 ++ 5 files changed, 9 insertions(+) diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/RecommendationAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/RecommendationAdapter.kt index 1fc97e7f..cde884fb 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/RecommendationAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/adapters/RecommendationAdapter.kt @@ -2,6 +2,7 @@ package com.intive.tmdbandroid.details.ui.adapters import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView @@ -54,6 +55,7 @@ class RecommendationAdapter(private val widthSize: Int, private val clickListene val circularProgressDrawable = CircularProgressDrawable(itemView.context).apply { strokeWidth = 5f centerRadius = 25f + setColorSchemeColors(ContextCompat.getColor(context, R.color.material_on_background_emphasis_high_type)) } circularProgressDrawable.start() diff --git a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/adapter/CombinedCreditsAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/adapter/CombinedCreditsAdapter.kt index be92a487..7d52b389 100644 --- a/app/src/main/java/com/intive/tmdbandroid/details/ui/person/adapter/CombinedCreditsAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/details/ui/person/adapter/CombinedCreditsAdapter.kt @@ -2,6 +2,7 @@ package com.intive.tmdbandroid.details.ui.person.adapter import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView @@ -46,6 +47,7 @@ class CombinedCreditsAdapter( val circularProgressDrawable = CircularProgressDrawable(itemView.context).apply { strokeWidth = 5f centerRadius = 25f + setColorSchemeColors(ContextCompat.getColor(context, R.color.material_on_background_emphasis_high_type)) } circularProgressDrawable.start() diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt index c1f1212d..e0ac9e04 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/ScreeningPageAdapter.kt @@ -48,6 +48,7 @@ class ScreeningPageAdapter(private val clickListener: (Screening) -> Unit) : Pag val circularProgressDrawable = CircularProgressDrawable(itemView.context).apply { strokeWidth = 5f centerRadius = 25f + setColorSchemeColors(ContextCompat.getColor(context, R.color.material_on_background_emphasis_high_type)) } circularProgressDrawable.start() diff --git a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt index 703eb4b4..d124f961 100644 --- a/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/home/ui/adapters/WatchlistAdapter.kt @@ -3,6 +3,7 @@ package com.intive.tmdbandroid.home.ui.adapters import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView @@ -50,6 +51,7 @@ class WatchlistAdapter(private val clickListener: ((Screening) -> Unit)) : ListA val circularProgressDrawable = CircularProgressDrawable(itemView.context).apply { strokeWidth = 5f centerRadius = 25f + setColorSchemeColors(ContextCompat.getColor(context, R.color.material_on_background_emphasis_high_type)) } circularProgressDrawable.start() diff --git a/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt b/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt index 1bec322f..1d659dd9 100644 --- a/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt +++ b/app/src/main/java/com/intive/tmdbandroid/search/ui/adapters/ScreeningSearchAdapter.kt @@ -2,6 +2,7 @@ package com.intive.tmdbandroid.search.ui.adapters import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView @@ -80,6 +81,7 @@ class ScreeningSearchAdapter( val circularProgressDrawable = CircularProgressDrawable(itemView.context).apply { strokeWidth = 5f centerRadius = 25f + setColorSchemeColors(ContextCompat.getColor(binding.root.context, R.color.material_on_background_emphasis_high_type)) } circularProgressDrawable.start() From f4a9416a2c393bd11053b5a7bebf76337f5c7fea Mon Sep 17 00:00:00 2001 From: Juan Dominguez Date: Wed, 13 Oct 2021 17:40:20 -0300 Subject: [PATCH 31/41] Move hardcoded dimensions from Rate dialog to dimens --- app/src/main/res/layout/rank_dialog.xml | 49 ++++++++++++------------- app/src/main/res/values/strings.xml | 6 +++ app/src/main/res/values/themes.xml | 4 +- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/app/src/main/res/layout/rank_dialog.xml b/app/src/main/res/layout/rank_dialog.xml index c0e145ee..dd4e7ad7 100644 --- a/app/src/main/res/layout/rank_dialog.xml +++ b/app/src/main/res/layout/rank_dialog.xml @@ -4,39 +4,43 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" - android:padding="2dip"> + android:paddingEnd="@dimen/margin_large" + android:paddingStart="@dimen/margin_large" + android:paddingTop="@dimen/margin_medium" + android:paddingBottom="@dimen/margin_medium"> + android:text="@string/rate_title" + android:textSize="@dimen/title_size" /> + android:layout_marginTop="@dimen/margin_medium" + android:text="@string/rate_subtitle" + android:textSize="@dimen/subtitle_size" /> + android:theme="@style/RatingBar" + /> + app:layout_constraintEnd_toStartOf="@+id/rank_dialog_button_rate" />