Skip to content

Commit 0e5808a

Browse files
authored
Merge pull request #36 from intive-FDV/improvements/sprint_3
Improvements/sprint 3
2 parents 6128fc4 + 64ec4b8 commit 0e5808a

File tree

108 files changed

+566
-948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+566
-948
lines changed

app/schemas/com.intive.tmdbandroid.datasource.local.LocalStorage/1.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"entities": [
77
{
88
"tableName": "ScreeningORMEntity",
9-
"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, `my_rate` REAL NOT NULL, `my_favorite` INTEGER NOT NULL, PRIMARY KEY(`id`))",
9+
"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`))",
1010
"fields": [
1111
{
1212
"fieldPath": "id",
@@ -68,12 +68,6 @@
6868
"affinity": "REAL",
6969
"notNull": true
7070
},
71-
{
72-
"fieldPath": "vote_count",
73-
"columnName": "vote_count",
74-
"affinity": "INTEGER",
75-
"notNull": true
76-
},
7771
{
7872
"fieldPath": "popularity",
7973
"columnName": "popularity",

app/src/androidTest/java/com/intive/tmdbandroid/datasource/local/LocalStorageTest.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.Context
44
import androidx.room.Room
55
import androidx.test.core.app.ApplicationProvider
66
import androidx.test.ext.junit.runners.AndroidJUnit4
7-
import com.intive.tmdbandroid.entity.ScreeningORMEntity
7+
import com.intive.tmdbandroid.entity.room.ScreeningORMEntity
88
import com.intive.tmdbandroid.model.Genre
99
import com.intive.tmdbandroid.model.Network
1010
import junit.framework.TestCase
@@ -33,13 +33,14 @@ class LocalStorageTest : TestCase() {
3333
poster_path = "POSTER_PATH",
3434
status = "Online",
3535
vote_average = 10.5,
36-
vote_count = 100,
3736
popularity = 34.0,
3837
media_type = "tv",
3938
adult = false,
4039
genre_ids = null,
4140
video = false,
42-
networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG"))
41+
networks = listOf(Network("/netflixlogo.jpg")),
42+
my_rate = 3.5,
43+
my_favorite = true
4344
)
4445

4546
private val screeningUpdate = ScreeningORMEntity(
@@ -54,13 +55,14 @@ class LocalStorageTest : TestCase() {
5455
poster_path = "POSTER_PATH_2",
5556
status = "Online",
5657
vote_average = 10.5,
57-
vote_count = 100,
5858
popularity = 34.0,
5959
media_type = "tv",
6060
adult = false,
6161
genre_ids = null,
6262
video = false,
63-
networks = listOf(Network("/netflixlogo.jpg", "netflix", 123, "ARG"))
63+
networks = listOf(Network("/netflixlogo.jpg")),
64+
my_rate = 3.5,
65+
my_favorite = true
6466
)
6567

6668
// Override function setUp() and annotate it with @Before
@@ -107,7 +109,7 @@ class LocalStorageTest : TestCase() {
107109
dao.insertFavorite(screening)
108110
val exists = dao.existAsFavorite(screening.id)
109111

110-
assertThat("Expecting result to be true", exists)
112+
assertThat("Expecting result to be true", exists == screening)
111113

112114
dao.updateFavorite(screeningUpdate)
113115
val tvShowsDeleted = dao.allFavorites()
@@ -122,6 +124,6 @@ class LocalStorageTest : TestCase() {
122124
fun writeAndReadOneFailureTest() = runBlocking {
123125
val exists = dao.existAsFavorite(screening.id)
124126

125-
assertThat("Expecting result to be true", !exists)
127+
assertThat("Expecting result to be true", exists != screening)
126128
}
127129
}

app/src/main/java/com/intive/tmdbandroid/common/RetrofitHelper.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
package com.intive.tmdbandroid.common
22

33
import com.intive.tmdbandroid.BuildConfig
4-
import retrofit2.Retrofit
5-
import retrofit2.converter.gson.GsonConverterFactory
64
import okhttp3.OkHttpClient
7-
85
import okhttp3.logging.HttpLoggingInterceptor
6+
import retrofit2.Retrofit
7+
import retrofit2.converter.gson.GsonConverterFactory
8+
import java.time.Duration
99

1010
object RetrofitHelper {
1111
fun getRetrofit() : Retrofit {
1212
val interceptor = HttpLoggingInterceptor()
1313
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
1414

15-
val client = OkHttpClient.Builder().addInterceptor(interceptor).build()
15+
val client = OkHttpClient.Builder()
16+
.addInterceptor(interceptor)
17+
.callTimeout(Duration.ofMinutes(1))
18+
.connectTimeout(Duration.ofSeconds(30))
19+
.readTimeout(Duration.ofSeconds(30))
20+
.writeTimeout(Duration.ofSeconds(30))
21+
.build()
1622

1723
return Retrofit.Builder()
1824
.baseUrl(BuildConfig.API_BASE_URL)

app/src/main/java/com/intive/tmdbandroid/common/ScreeningAsyncPagingDataDiffCallback.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/src/main/java/com/intive/tmdbandroid/datasource/ScreeningPagingSource.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ScreeningPagingSource(private val service: Service, private val type: Int)
1010
companion object {
1111
const val DEFAULT_PAGE_INDEX = 1
1212

13-
const val TYPE_TVSHOW = 1
13+
const val TYPE_TV_SHOW = 1
1414
const val TYPE_MOVIE = 2
1515
}
1616

@@ -21,13 +21,13 @@ class ScreeningPagingSource(private val service: Service, private val type: Int)
2121
lateinit var screenings: List<Screening>
2222

2323
when (type) {
24-
TYPE_TVSHOW -> {
24+
TYPE_TV_SHOW -> {
2525
service.getPaginatedPopularTVShows(pageNumber).collect { screenings = it.toScreeningList() }
2626
}
2727
TYPE_MOVIE -> {
2828
service.getPaginatedPopularMovies(pageNumber).collect { screenings = it.toScreeningList() }
2929
}
30-
else -> throw RuntimeException("Ilegal type parameter")
30+
else -> throw RuntimeException("Illegal type parameter")
3131
}
3232

3333

app/src/main/java/com/intive/tmdbandroid/datasource/local/Dao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.intive.tmdbandroid.datasource.local
22

33
import androidx.room.*
44
import androidx.room.Dao
5-
import com.intive.tmdbandroid.entity.ScreeningORMEntity
5+
import com.intive.tmdbandroid.entity.room.ScreeningORMEntity
66
import com.intive.tmdbandroid.entity.SessionORMEntity
77

88
@Dao

app/src/main/java/com/intive/tmdbandroid/datasource/local/LocalStorage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.intive.tmdbandroid.datasource.local
33
import androidx.room.Database
44
import androidx.room.RoomDatabase
55
import androidx.room.TypeConverters
6-
import com.intive.tmdbandroid.entity.ScreeningORMEntity
6+
import com.intive.tmdbandroid.entity.room.ScreeningORMEntity
77
import com.intive.tmdbandroid.entity.SessionORMEntity
88
import com.intive.tmdbandroid.model.converter.GenreConverter
99
import com.intive.tmdbandroid.model.converter.IntConverter

app/src/main/java/com/intive/tmdbandroid/datasource/network/ApiClient.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.intive.tmdbandroid.datasource.network
22

3-
import com.intive.tmdbandroid.entity.*
3+
import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies
4+
import com.intive.tmdbandroid.entity.network.ResultCombinedCredits
5+
import com.intive.tmdbandroid.entity.person.ResultPeopleEntity
6+
import com.intive.tmdbandroid.entity.person.ResultPerson
7+
import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity
8+
import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity
9+
import com.intive.tmdbandroid.entity.video.VideoEntity
410
import com.intive.tmdbandroid.model.Movie
511
import com.intive.tmdbandroid.model.Session
612
import com.intive.tmdbandroid.model.TVShow

app/src/main/java/com/intive/tmdbandroid/datasource/network/Service.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ package com.intive.tmdbandroid.datasource.network
22

33
import com.intive.tmdbandroid.BuildConfig
44
import com.intive.tmdbandroid.common.RetrofitHelper
5-
import com.intive.tmdbandroid.entity.*
5+
import com.intive.tmdbandroid.entity.network.ResultListTVShowOrMovies
6+
import com.intive.tmdbandroid.entity.movie.ResultMoviesEntity
7+
import com.intive.tmdbandroid.entity.person.ResultPeopleEntity
8+
import com.intive.tmdbandroid.entity.person.ResultPerson
9+
import com.intive.tmdbandroid.entity.tvshow.ResultTVShowsEntity
610
import com.intive.tmdbandroid.model.Movie
711
import com.intive.tmdbandroid.model.Screening
812
import com.intive.tmdbandroid.model.TVShow

app/src/main/java/com/intive/tmdbandroid/detailandsearch/ui/DetailAndSearchActivity.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ class DetailAndSearchActivity : AppCompatActivity() {
1313
super.onCreate(savedInstanceState)
1414
val binding = ActivityDetailAndSearchBinding.inflate(layoutInflater)
1515
setContentView(binding.root)
16+
val context = binding.root.context
1617

1718
val navHost = supportFragmentManager.findFragmentById(R.id.nav_host_detail_and_search) as NavHostFragment
1819
val navController = navHost.navController
1920

2021
val graph = navController
2122
.navInflater.inflate(R.navigation.nav_graph)
2223

23-
val action = intent.extras?.getString("action", "search")
24+
val action = intent.extras?.getString(
25+
context.getString(R.string.intent_extra_key_action),
26+
context.getString(R.string.intent_extra_key_action_default)
27+
)
28+
2429
action.let {
25-
if (it.equals("search")){
30+
if (it.equals(context.getString(R.string.intent_extra_key_action_default))){
2631
graph.startDestination = R.id.searchFragmentDest
2732
} else {
2833
graph.startDestination = R.id.detailFragmentDest

0 commit comments

Comments
 (0)