Skip to content

Commit

Permalink
Merge pull request #74 from RajashekarRaju/migrate-to-ktor
Browse files Browse the repository at this point in the history
Migrate network operations from HttpURLConnection to Ktor
  • Loading branch information
RajashekarRaju authored Dec 20, 2024
2 parents ea07b95 + c8c59cc commit 0cb87ac
Show file tree
Hide file tree
Showing 36 changed files with 377 additions and 534 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/androidTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ jobs:
- name: Upload Failing Test Report Log
if: steps.testing.outcome != 'success'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: logs
path: app/emulator.log

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build-outputs
path: ./app/build/outputs

- name: Upload build reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build-reports
path: ./app/build/reports
Expand Down
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.com.google.gms)
alias(libs.plugins.com.google.firebase)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.serialization)
}

android {
Expand Down Expand Up @@ -116,6 +117,15 @@ dependencies {
implementation(libs.androidx.paging.paging.compose)
implementation(libs.androidx.paging.paging.runtime.ktx)

implementation(platform(libs.ktor.bom))
implementation(libs.ktor.client.android)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.ktor.client.logging)
implementation(libs.ktor.client.serialization)

implementation(libs.kotlinx.coroutines.core)

testImplementation(libs.androidx.compose.ui.ui.test.junit4)
testImplementation(libs.io.mockk)

Expand Down
35 changes: 33 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,39 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-renamesourcefileattribute SourceFile

# Kotlinx.serialization
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class <1> {
public static <1> INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}

-if @kotlinx.serialization.Serializable class **
-keep class <1> { *; }

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.developersbreach.composeactors.data

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PagedResponse<T>(
val data: List<T>,
val total: Int,
val page: Int,
@SerialName("total_pages") val totalPages: Int,
@SerialName("page") val page: Int,
@SerialName("results") val data: List<T>
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.developersbreach.composeactors.data.datasource.database.entity.Favori

@Database(
entities = [FavoriteActorsEntity::class, FavoriteMoviesEntity::class],
version = 3,
exportSchema = false
version = 4,
exportSchema = false,
)
abstract class AppDatabase : RoomDatabase() {
abstract val favoriteActorsDao: FavoriteActorsDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ data class FavoriteActorsEntity(
val actorProfileUrl: String,

@ColumnInfo(name = "column_actor_placeOfBirth")
val actorPlaceOfBirth: String
val actorPlaceOfBirth: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data class FavoriteMoviesEntity(
val movieName: String,

@ColumnInfo(name = "column_movie_posterUrl")
val moviePosterUrl: String,
val moviePosterUrl: String?,

@ColumnInfo(name = "column_movie_banner")
val movieBanner: String
val movieBanner: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,32 @@ val popularActorList = listOf(
Actor(
actorId = 28782,
actorName = "Monica Bellucci",
profileUrl = "z3sLuRKP7hQVrvSTsqdLjGSldwG.jpg"
profilePath = "z3sLuRKP7hQVrvSTsqdLjGSldwG.jpg"
),
Actor(
actorId = 287,
actorName = "Brad Pitt",
profileUrl = "kU3B75TyRiCgE270EyZnHjfivoq.jpg"
profilePath = "kU3B75TyRiCgE270EyZnHjfivoq.jpg"
)
)

val trendingActorList = listOf(
Actor(
actorId = 8784,
actorName = "Daniel Craig",
profileUrl = "rFuETZeyOAfIqBahOObF7Soq5Dh.jpg"
profilePath = "rFuETZeyOAfIqBahOObF7Soq5Dh.jpg"
),
Actor(
actorId = 1892,
actorName = "Matt Damon",
profileUrl = "7wbHIn7GziFlJLPl8Zu1XVl24EG.jpg"
profilePath = "7wbHIn7GziFlJLPl8Zu1XVl24EG.jpg"
),
)

val fakeActorDetail = ActorDetail(
actorId = 28782,
actorName = "Monica Bellucci",
profileUrl = "z3sLuRKP7hQVrvSTsqdLjGSldwG.jpg",
profilePath = "z3sLuRKP7hQVrvSTsqdLjGSldwG.jpg",
biography = "This is fake biography for the actor added here to see how the actual preview looks in the screen so don't get any serious about this.",
dateOfBirth = "59",
placeOfBirth = "Italy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.developersbreach.composeactors.data.datasource.fake
import com.developersbreach.composeactors.data.model.Genre
import com.developersbreach.composeactors.data.model.Movie
import com.developersbreach.composeactors.data.model.MovieDetail
import com.developersbreach.composeactors.data.model.ProductionCompanies

fun fakeMovieList(): MutableList<Movie> {
val movies = mutableListOf<Movie>()
Expand All @@ -29,33 +30,46 @@ fun fakeMovieList(): MutableList<Movie> {

val upcomingMoviesList = listOf(
Movie(
movieId = 363736, movieName = "Oppenheimer", posterPathUrl = "", bannerUrl = ""
movieId = 363736, movieName = "Oppenheimer", posterPath = "", backdropPath = ""
),
Movie(
movieId = 123434, movieName = "Dune", posterPathUrl = "", bannerUrl = ""
movieId = 123434, movieName = "Dune", posterPath = "", backdropPath = ""
)
)

val nowPlayingMoviesList = listOf(
Movie(
movieId = 157336, movieName = "Interstellar", posterPathUrl = "", bannerUrl = ""
movieId = 157336, movieName = "Interstellar", posterPath = "", backdropPath = ""
),
Movie(
movieId = 244786, movieName = "Whiplash", posterPathUrl = "", bannerUrl = ""
movieId = 244786, movieName = "Whiplash", posterPath = "", backdropPath = ""
)
)

private val fakeProductionCompanies = listOf(
ProductionCompanies(
id = 7228,
logoPath = "rrbt",
name = "Bad movies company"
),
ProductionCompanies(
id = 7228,
logoPath = "rrbt",
name = "Silly company"
),
)

val fakeMovieDetail = MovieDetail(
movieId = 12345,
movieTitle = "Pulp Fiction",
banner = "banner-url.jpeg",
budget = "20 Million",
backdropPath = "banner-url.jpeg",
budget = 20_00_000,
genres = listOf(Genre(1, "Thriller"), Genre(2, "Crime")),
originalLanguage = "English",
overview = "In the realm of underworld, a series of incidents intertwines the lives of two Los Angeles mobsters, a gangster's wife, a boxer and two small-time criminals.",
popularity = 99.0,
poster = "poster-url.jpeg",
productionCompanies = listOf("Whatever, WhoCares"),
posterPath = "poster-url.jpeg",
productionCompanies = fakeProductionCompanies,
releaseDate = "1994",
revenue = 21400000,
runtime = 154,
Expand Down
Loading

0 comments on commit 0cb87ac

Please sign in to comment.