mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Fixes #340 Improve CSV file export
This commit is contained in:
parent
51c8a6a315
commit
6012bddbdc
5 changed files with 125 additions and 61 deletions
|
|
@ -3,9 +3,11 @@ package com.geeksville.mesh.database
|
|||
import androidx.lifecycle.LiveData
|
||||
import com.geeksville.mesh.database.dao.PacketDao
|
||||
import com.geeksville.mesh.database.entity.Packet
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class PacketRepository(private val packetDao : PacketDao) {
|
||||
val allPackets : LiveData<List<Packet>> = packetDao.getAllPacket(500)
|
||||
val allPackets : LiveData<List<Packet>> = packetDao.getAllPacket(MAX_ITEMS)
|
||||
val allPacketsInReceiveOrder : Flow<List<Packet>> = packetDao.getAllPacketsInReceiveOrder(MAX_ITEMS)
|
||||
|
||||
suspend fun insert(packet: Packet) {
|
||||
packetDao.insert(packet)
|
||||
|
|
@ -14,4 +16,9 @@ class PacketRepository(private val packetDao : PacketDao) {
|
|||
suspend fun deleteAll() {
|
||||
packetDao.deleteAll()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MAX_ITEMS = 500
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import androidx.room.Dao
|
|||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import com.geeksville.mesh.database.entity.Packet
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface PacketDao {
|
||||
|
|
@ -12,6 +13,9 @@ interface PacketDao {
|
|||
@Query("Select * from packet order by received_date desc limit 0,:maxItem")
|
||||
fun getAllPacket(maxItem: Int): LiveData<List<Packet>>
|
||||
|
||||
@Query("Select * from packet order by received_date asc limit 0,:maxItem")
|
||||
fun getAllPacketsInReceiveOrder(maxItem: Int): Flow<List<Packet>>
|
||||
|
||||
@Insert
|
||||
fun insert(packet: Packet)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue