-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from RajashekarRaju/restructure-architecture
Restructure project architecture, improve testability, separated classes to packages by features
- Loading branch information
Showing
104 changed files
with
1,222 additions
and
1,119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/developersbreach/composeactors/core/database/AppDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.developersbreach.composeactors.core.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import com.developersbreach.composeactors.core.database.dao.FavoritePersonsDao | ||
import com.developersbreach.composeactors.core.database.dao.FavoriteMoviesDao | ||
import com.developersbreach.composeactors.core.database.entity.FavoritePersonsEntity | ||
import com.developersbreach.composeactors.core.database.entity.FavoriteMoviesEntity | ||
|
||
|
||
@Database( | ||
entities = [FavoritePersonsEntity::class, FavoriteMoviesEntity::class], | ||
version = 4, | ||
exportSchema = false, | ||
) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract val favoritePersonsDao: FavoritePersonsDao | ||
abstract val favoriteMoviesDao: FavoriteMoviesDao | ||
} |
4 changes: 2 additions & 2 deletions
4
...asource/database/dao/FavoriteMoviesDao.kt → ...rs/core/database/dao/FavoriteMoviesDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/developersbreach/composeactors/core/database/dao/FavoritePersonsDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.developersbreach.composeactors.core.database.dao | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.* | ||
import com.developersbreach.composeactors.core.database.entity.FavoritePersonsEntity | ||
|
||
@Dao | ||
interface FavoritePersonsDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun addPersonToFavorites(favoritePersonsEntity: FavoritePersonsEntity) | ||
|
||
@Query("SELECT * FROM favorite_persons_table") | ||
fun getAllFavoritePersons(): LiveData<List<FavoritePersonsEntity>> | ||
|
||
@Query("DELETE FROM favorite_persons_table") | ||
fun deleteAllFavoritePersons() | ||
|
||
@Delete | ||
fun deleteSelectedFavoritePerson(favoritePersonsEntity: FavoritePersonsEntity) | ||
|
||
@Query("SELECT column_person_id FROM favorite_persons_table WHERE column_person_id = :personId") | ||
fun checkIfPersonIsFavorite(personId: Int): LiveData<Int> | ||
} |
2 changes: 1 addition & 1 deletion
2
...e/database/entity/FavoriteMoviesEntity.kt → ...e/database/entity/FavoriteMoviesEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ain/java/com/developersbreach/composeactors/core/database/entity/FavoritePersonsEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.developersbreach.composeactors.core.database.entity | ||
|
||
import androidx.compose.runtime.Stable | ||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "favorite_persons_table") | ||
data class FavoritePersonsEntity( | ||
|
||
@Stable | ||
@PrimaryKey | ||
@ColumnInfo(name = "column_person_id") | ||
val personId: Int, | ||
|
||
@ColumnInfo(name = "column_person_name") | ||
val personName: String, | ||
|
||
@ColumnInfo(name = "column_person_profileUrl") | ||
val personProfileUrl: String, | ||
|
||
@ColumnInfo(name = "column_person_placeOfBirth") | ||
val personPlaceOfBirth: String? | ||
) |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/developersbreach/composeactors/core/network/BaseUrlProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.developersbreach.composeactors.core.network | ||
|
||
import java.io.UnsupportedEncodingException | ||
import java.net.URLEncoder | ||
import java.nio.charset.StandardCharsets | ||
|
||
open class BaseUrlProvider { | ||
|
||
fun String.toEncodedQuery(): String { | ||
return try { | ||
URLEncoder.encode(this, StandardCharsets.UTF_8.toString()) | ||
} catch (e: UnsupportedEncodingException) { | ||
throw IllegalArgumentException("Failed to encode query: $this", e) | ||
} | ||
} | ||
|
||
protected companion object { | ||
const val BASE_URL = "https://api.themoviedb.org/3/" | ||
const val API_KEY = "api_key=${TmdbApiKey.TMDB_API_KEY}" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rsbreach/composeactors/utils/Constants.kt → ...h/composeactors/core/network/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.developersbreach.composeactors.utils | ||
package com.developersbreach.composeactors.core.network | ||
|
||
const val LOW_RES_IMAGE = "https://image.tmdb.org/t/p/w200" | ||
const val HIGH_RES_IMAGE = "https://image.tmdb.org/t/p/w500" |
3 changes: 1 addition & 2 deletions
3
...composeactors/utils/HttpRequestHandler.kt → ...actors/core/network/HttpRequestHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...reach/composeactors/data/PagedResponse.kt → ...mposeactors/core/network/PagedResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
app/src/main/java/com/developersbreach/composeactors/data/datasource/database/AppDatabase.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
...java/com/developersbreach/composeactors/data/datasource/database/dao/FavoriteActorsDao.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...om/developersbreach/composeactors/data/datasource/database/entity/FavoriteActorsEntity.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.