-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #252 Signed-off-by: IacobIonut01 <[email protected]>
- Loading branch information
1 parent
344ec1a
commit 1fbace7
Showing
18 changed files
with
566 additions
and
16 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/schemas/com.dot.gallery.feature_node.data.data_source.InternalDatabase/2.json
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,60 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 2, | ||
"identityHash": "57402321aff199c16e2f25a4a21623ba", | ||
"entities": [ | ||
{ | ||
"tableName": "pinned_table", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, PRIMARY KEY(`id`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "blacklist", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `label` TEXT NOT NULL, PRIMARY KEY(`id`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "label", | ||
"columnName": "label", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"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, '57402321aff199c16e2f25a4a21623ba')" | ||
] | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
app/src/main/kotlin/com/dot/gallery/feature_node/data/data_source/BlacklistDao.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,25 @@ | ||
package com.dot.gallery.feature_node.data.data_source | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Query | ||
import androidx.room.Upsert | ||
import com.dot.gallery.feature_node.domain.model.BlacklistedAlbum | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Dao | ||
interface BlacklistDao { | ||
|
||
@Query("SELECT * FROM blacklist") | ||
fun getBlacklistedAlbums(): Flow<List<BlacklistedAlbum>> | ||
|
||
@Upsert | ||
suspend fun addBlacklistedAlbum(blacklistedAlbum: BlacklistedAlbum) | ||
|
||
@Delete | ||
suspend fun removeBlacklistedAlbum(blacklistedAlbum: BlacklistedAlbum) | ||
|
||
@Query("SELECT EXISTS(SELECT * FROM blacklist WHERE id = :albumId)") | ||
fun albumIsBlacklisted(albumId: Long): Boolean | ||
|
||
} |
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
14 changes: 14 additions & 0 deletions
14
app/src/main/kotlin/com/dot/gallery/feature_node/domain/model/BlacklistedAlbum.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,14 @@ | ||
package com.dot.gallery.feature_node.domain.model | ||
|
||
import android.os.Parcelable | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Entity(tableName = "blacklist") | ||
@Parcelize | ||
data class BlacklistedAlbum( | ||
@PrimaryKey(autoGenerate = false) | ||
val id: Long, | ||
val label: String | ||
): Parcelable |
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
18 changes: 18 additions & 0 deletions
18
app/src/main/kotlin/com/dot/gallery/feature_node/domain/use_case/BlacklistUseCase.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,18 @@ | ||
package com.dot.gallery.feature_node.domain.use_case | ||
|
||
import com.dot.gallery.feature_node.domain.model.BlacklistedAlbum | ||
import com.dot.gallery.feature_node.domain.repository.MediaRepository | ||
|
||
class BlacklistUseCase( | ||
private val repository: MediaRepository | ||
) { | ||
|
||
suspend fun addToBlacklist(blacklistedAlbum: BlacklistedAlbum) = | ||
repository.addBlacklistedAlbum(blacklistedAlbum) | ||
|
||
suspend fun removeFromBlacklist(blacklistedAlbum: BlacklistedAlbum) = | ||
repository.removeBlacklistedAlbum(blacklistedAlbum) | ||
|
||
val blacklistedAlbums by lazy { repository.getBlacklistedAlbums() } | ||
|
||
} |
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
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
Oops, something went wrong.