-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,722 additions
and
1,200 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
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
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
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
18 changes: 18 additions & 0 deletions
18
app/src/main/kotlin/ac/mdiq/podcini/storage/model/Rating.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 ac.mdiq.podcini.storage.model | ||
|
||
import ac.mdiq.podcini.R | ||
|
||
enum class Rating(val code: Int, val res: Int) { | ||
UNRATED(-3, R.drawable.ic_questionmark), | ||
TRASH(-2, R.drawable.ic_delete), | ||
BAD(-1, androidx.media3.session.R.drawable.media3_icon_thumb_down_filled), | ||
NEUTRAL(0, R.drawable.baseline_sentiment_neutral_24), | ||
GOOD(1, androidx.media3.session.R.drawable.media3_icon_thumb_up_filled), | ||
FAVORITE(2, R.drawable.ic_star); | ||
|
||
companion object { | ||
fun fromCode(code: Int): Rating { | ||
return enumValues<Rating>().firstOrNull { it.code == code } ?: NEUTRAL | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
app/src/main/kotlin/ac/mdiq/podcini/storage/model/SubscriptionLog.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,68 @@ | ||
package ac.mdiq.podcini.storage.model | ||
|
||
import ac.mdiq.podcini.storage.database.RealmDB.realm | ||
import ac.mdiq.podcini.util.Logd | ||
import io.realm.kotlin.types.RealmObject | ||
import io.realm.kotlin.types.annotations.PrimaryKey | ||
import java.util.* | ||
|
||
class SubscriptionLog: RealmObject { | ||
@PrimaryKey | ||
var id: Long = 0L // this is the Date().time | ||
|
||
// this can be that of a feed or a synthetic episode | ||
// var itemId: Long = 0L | ||
|
||
var url: String? = null | ||
|
||
var link: String? = null | ||
|
||
var title: String = "" | ||
|
||
var type: String? = null | ||
|
||
var cancelDate: Long = 0 | ||
|
||
var rating: Int = Rating.UNRATED.code | ||
|
||
var comment: String = "" | ||
|
||
constructor() {} | ||
|
||
constructor(itemId: Long, title: String, url: String, link: String, type: String) { | ||
// this.itemId = itemId | ||
this.title = title | ||
this.url = url | ||
this.link = link | ||
this.type = type | ||
|
||
// itemId being either feed.id or episode.id is 100 times the creation time | ||
id = itemId / 100 | ||
} | ||
|
||
enum class Type { | ||
Feed, | ||
Media, | ||
} | ||
|
||
companion object { | ||
val TAG: String = SubscriptionLog::class.simpleName ?: "Anonymous" | ||
|
||
var feedLogsMap: Map<String, SubscriptionLog>? = null | ||
get() { | ||
if (field == null) field = getFeedLogMap() | ||
return field | ||
} | ||
|
||
fun getFeedLogMap(): Map<String, SubscriptionLog> { | ||
val logs = realm.query(SubscriptionLog::class).query("type == $0", "Feed").find() | ||
val map = mutableMapOf<String, SubscriptionLog>() | ||
for (l in logs) { | ||
Logd(TAG, "getFeedLogMap ${l.title} ${l.url}") | ||
if (!l.url.isNullOrEmpty()) map[l.url!!] = l | ||
if (!l.link.isNullOrEmpty()) map[l.link!!] = l | ||
} | ||
return map.toMap() | ||
} | ||
} | ||
} |
Oops, something went wrong.