kopia lustrzana https://github.com/sh123/codec2_talkie
Indices
rodzic
bbf4000579
commit
48a9ac86d2
|
@ -20,7 +20,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
|
||||
@androidx.room.Database(
|
||||
version = 7,
|
||||
version = 9,
|
||||
entities = {LogItem.class, MessageItem.class, PositionItem.class, StationItem.class},
|
||||
exportSchema = false
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.room.PrimaryKey;
|
|||
|
||||
import com.radio.codec2talkie.storage.station.StationItem;
|
||||
|
||||
@Entity
|
||||
@Entity(indices = {@Index(value = {"id", "srcCallsign"}, unique = true)})
|
||||
public class LogItem {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.radio.codec2talkie.storage.message;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
@Entity(indices = {@Index(value = {"id", "srcCallsign"}, unique = true)})
|
||||
public class MessageItem {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.radio.codec2talkie.storage.position;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import com.radio.codec2talkie.protocol.position.Position;
|
||||
|
||||
@Entity
|
||||
@Entity(indices = {@Index(value = {"id", "srcCallsign"}, unique = true)})
|
||||
public class PositionItem {
|
||||
|
||||
private static final double MIN_COORDINATE_CHANGE_DELTA = 0.003;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.radio.codec2talkie.storage.station;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
@Entity(indices = {@Index(value = {"id", "srcCallsign"}, unique = true)})
|
||||
public class StationItem {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
@ -45,11 +46,11 @@ public class StationItem {
|
|||
|
||||
public double getBearingDegrees() { return bearingDegrees; }
|
||||
|
||||
public double getSpeedMetersPerSecond() { return speedMetersPerSecond; };
|
||||
public double getSpeedMetersPerSecond() { return speedMetersPerSecond; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
|
||||
public String getComment() { return comment; };
|
||||
public String getComment() { return comment; }
|
||||
|
||||
public String getSymbolCode() { return symbolCode; }
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ import androidx.room.OnConflictStrategy;
|
|||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import com.radio.codec2talkie.storage.position.PositionItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
|
|
|
@ -26,13 +26,13 @@ public class StationItemRepository {
|
|||
public void upsertStationItem(StationItem stationItem) {
|
||||
AppDatabase.getDatabaseExecutor().execute(() -> {
|
||||
StationItem oldStationItem = _stationItemDao.getStationItem(stationItem.getSrcCallsign());
|
||||
if (oldStationItem != null) {
|
||||
if (oldStationItem == null) {
|
||||
_stationItemDao.insertStationItem(stationItem);
|
||||
Log.i(TAG, "INSERT " + stationItem.getSrcCallsign());
|
||||
} else {
|
||||
oldStationItem.updateFrom(stationItem);
|
||||
_stationItemDao.updateStationItem(oldStationItem);
|
||||
Log.i(TAG, "UPDATE " + oldStationItem.getSrcCallsign());
|
||||
} else {
|
||||
_stationItemDao.insertStationItem(stationItem);
|
||||
Log.i(TAG, "INSERT " + stationItem.getSrcCallsign());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue