-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress with notifications and network reports screens.
- Loading branch information
Showing
46 changed files
with
582 additions
and
15 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
24 changes: 24 additions & 0 deletions
24
subvt/src/main/java/io/helikon/subvt/data/dao/NotificationDAO.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 io.helikon.subvt.data.dao | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import io.helikon.subvt.data.model.Notification | ||
import java.util.UUID | ||
|
||
@Dao | ||
interface NotificationDAO { | ||
@Query("SELECT * from notification") | ||
fun getAll(): LiveData<List<Notification>> | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insert(notification: Notification) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insertAll(notifications: List<Notification>) | ||
|
||
@Query("SELECT * FROM notification WHERE id = :id") | ||
fun findById(id: UUID): Notification? | ||
} |
16 changes: 16 additions & 0 deletions
16
subvt/src/main/java/io/helikon/subvt/data/db/RoomConverters.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,16 @@ | ||
package io.helikon.subvt.data.db | ||
|
||
import androidx.room.TypeConverter | ||
import java.util.Date | ||
|
||
class RoomConverters { | ||
@TypeConverter | ||
fun dateFromTimestamp(value: Long?): Date? { | ||
return value?.let { Date(it) } | ||
} | ||
|
||
@TypeConverter | ||
fun dateToTimestamp(date: Date?): Long? { | ||
return date?.time?.toLong() | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
subvt/src/main/java/io/helikon/subvt/data/model/Notification.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,31 @@ | ||
package io.helikon.subvt.data.model | ||
|
||
import android.os.Parcelable | ||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import kotlinx.parcelize.Parcelize | ||
import java.util.Date | ||
import java.util.UUID | ||
|
||
@Entity(tableName = "notification") | ||
@Parcelize | ||
data class Notification( | ||
@PrimaryKey(autoGenerate = false) | ||
@ColumnInfo(name = "id") | ||
val id: UUID, | ||
@ColumnInfo(name = "is_read") | ||
val isRead: Boolean, | ||
@ColumnInfo(name = "message") | ||
val message: String, | ||
@ColumnInfo(name = "network_id") | ||
val networkId: Long, | ||
@ColumnInfo(name = "notification_type_code") | ||
val notificationTypeCode: String, | ||
@ColumnInfo(name = "received_at") | ||
val receivedAt: Date, | ||
@ColumnInfo(name = "validator_account_id") | ||
val validatorAccountId: String, | ||
@ColumnInfo(name = "validator_display") | ||
val validatorDisplay: String, | ||
) : Parcelable |
20 changes: 20 additions & 0 deletions
20
subvt/src/main/java/io/helikon/subvt/data/repository/NotificationRepository.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,20 @@ | ||
package io.helikon.subvt.data.repository | ||
|
||
import androidx.lifecycle.LiveData | ||
import io.helikon.subvt.data.dao.NotificationDAO | ||
import io.helikon.subvt.data.model.Notification | ||
import java.util.UUID | ||
|
||
class NotificationRepository(private val dao: NotificationDAO) { | ||
val allNotifications: LiveData<List<Notification>> = dao.getAll() | ||
|
||
suspend fun add(notification: Notification) { | ||
dao.insert(notification) | ||
} | ||
|
||
suspend fun addAll(notifications: List<Notification>) { | ||
dao.insertAll(notifications) | ||
} | ||
|
||
suspend fun findById(id: UUID): Notification? = dao.findById(id) | ||
} |
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.