feat: implement Android data models in Kotlin
- Add FeedItem, Feed, FeedSubscription models with Moshi JSON support - Add SearchResult, SearchFilters models with sealed classes for enums - Add NotificationPreferences, ReadingPreferences models - Add Room Entity annotations for database readiness - Add TypeConverters for Date and List<String> serialization - Add Parcelize for passing models between Activities/Fragments - Write comprehensive unit tests for serialization/deserialization - Write tests for copy(), equals/hashCode, and toString functionality
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.rssuper.models
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import androidx.room.TypeConverters
|
||||
import com.rssuper.converters.DateConverter
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import java.util.Date
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
@Parcelize
|
||||
@TypeConverters(DateConverter::class)
|
||||
@Entity(tableName = "feed_subscriptions")
|
||||
data class FeedSubscription(
|
||||
@PrimaryKey
|
||||
val id: String,
|
||||
|
||||
@Json(name = "url")
|
||||
val url: String,
|
||||
|
||||
@Json(name = "title")
|
||||
val title: String,
|
||||
|
||||
@Json(name = "category")
|
||||
val category: String? = null,
|
||||
|
||||
@Json(name = "enabled")
|
||||
val enabled: Boolean = true,
|
||||
|
||||
@Json(name = "fetchInterval")
|
||||
val fetchInterval: Long,
|
||||
|
||||
@Json(name = "createdAt")
|
||||
val createdAt: Date,
|
||||
|
||||
@Json(name = "updatedAt")
|
||||
val updatedAt: Date,
|
||||
|
||||
@Json(name = "lastFetchedAt")
|
||||
val lastFetchedAt: Date? = null,
|
||||
|
||||
@Json(name = "nextFetchAt")
|
||||
val nextFetchAt: Date? = null,
|
||||
|
||||
@Json(name = "error")
|
||||
val error: String? = null,
|
||||
|
||||
@Json(name = "httpAuth")
|
||||
val httpAuth: HttpAuth? = null
|
||||
) : Parcelable
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
@Parcelize
|
||||
data class HttpAuth(
|
||||
@Json(name = "username")
|
||||
val username: String,
|
||||
|
||||
@Json(name = "password")
|
||||
val password: String
|
||||
) : Parcelable
|
||||
Reference in New Issue
Block a user