- 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
50 lines
1.0 KiB
Kotlin
50 lines
1.0 KiB
Kotlin
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 = "search_results")
|
|
data class SearchResult(
|
|
@PrimaryKey
|
|
val id: String,
|
|
|
|
@Json(name = "type")
|
|
val type: SearchResultType,
|
|
|
|
@Json(name = "title")
|
|
val title: String,
|
|
|
|
@Json(name = "snippet")
|
|
val snippet: String? = null,
|
|
|
|
@Json(name = "link")
|
|
val link: String? = null,
|
|
|
|
@Json(name = "feedTitle")
|
|
val feedTitle: String? = null,
|
|
|
|
@Json(name = "published")
|
|
val published: Date? = null,
|
|
|
|
@Json(name = "score")
|
|
val score: Double? = null
|
|
) : Parcelable
|
|
|
|
enum class SearchResultType {
|
|
@Json(name = "article")
|
|
ARTICLE,
|
|
|
|
@Json(name = "feed")
|
|
FEED
|
|
}
|