mirror of
https://github.com/ev-map/EVMap.git
synced 2025-12-23 23:27:46 -05:00
re-add PredictionRepository so that Tesla congestion data is displayed
ref 17a82591a5
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package net.vonforst.evmap.api.fronyx
|
||||
|
||||
import android.content.Context
|
||||
import com.squareup.moshi.JsonDataException
|
||||
import net.vonforst.evmap.R
|
||||
import net.vonforst.evmap.api.availability.AvailabilityDetectorException
|
||||
import net.vonforst.evmap.api.availability.AvailabilityRepository
|
||||
import net.vonforst.evmap.api.availability.ChargeLocationStatus
|
||||
import net.vonforst.evmap.api.equivalentPlugTypes
|
||||
import net.vonforst.evmap.api.nameForPlugType
|
||||
@@ -13,8 +10,6 @@ import net.vonforst.evmap.model.ChargeLocation
|
||||
import net.vonforst.evmap.model.Chargepoint
|
||||
import net.vonforst.evmap.storage.PreferenceDataSource
|
||||
import net.vonforst.evmap.viewmodel.Resource
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
@@ -55,9 +50,9 @@ class PredictionRepository(private val context: Context) {
|
||||
evseIds: Map<Chargepoint, List<String>>,
|
||||
filteredConnectors: Set<String>?
|
||||
): Resource<List<FronyxEvseIdResponse>> {
|
||||
if (!prefs.predictionEnabled) return Resource.success(null)
|
||||
return Resource.success(null)
|
||||
|
||||
val allEvseIds =
|
||||
/*val allEvseIds =
|
||||
evseIds.filterKeys {
|
||||
FronyxApi.isChargepointSupported(charger, it) &&
|
||||
filteredConnectors?.let { filtered ->
|
||||
@@ -89,7 +84,7 @@ class PredictionRepository(private val context: Context) {
|
||||
// malformed JSON response from fronyx API
|
||||
e.printStackTrace()
|
||||
return Resource.error(e.message, null)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun buildPredictionGraph(
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.vonforst.evmap.api.availability.tesla.Pricing
|
||||
import net.vonforst.evmap.api.chargeprice.ChargepriceApi
|
||||
import net.vonforst.evmap.api.createApi
|
||||
import net.vonforst.evmap.api.fronyx.PredictionData
|
||||
import net.vonforst.evmap.api.fronyx.PredictionRepository
|
||||
import net.vonforst.evmap.model.ChargeLocation
|
||||
import net.vonforst.evmap.model.Cost
|
||||
import net.vonforst.evmap.model.FaultReport
|
||||
@@ -81,7 +82,7 @@ class ChargerDetailScreen(ctx: CarContext, val chargerSparse: ChargeLocation) :
|
||||
ChargeLocationsRepository(createApi(prefs.dataSource, ctx), lifecycleScope, db, prefs)
|
||||
private val availabilityRepo = AvailabilityRepository(ctx)
|
||||
|
||||
//private val predictionRepo = PredictionRepository(ctx)
|
||||
private val predictionRepo = PredictionRepository(ctx)
|
||||
private val timeFormat = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)
|
||||
|
||||
private val imageSize = 128 // images should be 128dp according to docs
|
||||
@@ -559,7 +560,7 @@ class ChargerDetailScreen(ctx: CarContext, val chargerSparse: ChargeLocation) :
|
||||
|
||||
invalidate()
|
||||
|
||||
//prediction = predictionRepo.getPredictionData(charger, availability)
|
||||
prediction = predictionRepo.getPredictionData(charger, availability)
|
||||
|
||||
invalidate()
|
||||
} else {
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.vonforst.evmap.api.availability.ChargeLocationStatus
|
||||
import net.vonforst.evmap.api.availability.tesla.Pricing
|
||||
import net.vonforst.evmap.api.createApi
|
||||
import net.vonforst.evmap.api.fronyx.PredictionData
|
||||
import net.vonforst.evmap.api.fronyx.PredictionRepository
|
||||
import net.vonforst.evmap.api.goingelectric.GEChargepoint
|
||||
import net.vonforst.evmap.api.openchargemap.OCMConnection
|
||||
import net.vonforst.evmap.api.openchargemap.OCMReferenceData
|
||||
@@ -265,14 +266,13 @@ class MapViewModel(application: Application, private val state: SavedStateHandle
|
||||
it.data?.extraData as? Pricing
|
||||
}
|
||||
|
||||
//private val predictionRepository = PredictionRepository(application)
|
||||
private val predictionRepository = PredictionRepository(application)
|
||||
|
||||
val predictionData: LiveData<PredictionData> = availability.switchMap { av ->
|
||||
/*liveData {
|
||||
liveData {
|
||||
val charger = charger.value?.data ?: return@liveData
|
||||
emit(predictionRepository.getPredictionData(charger, av.data, filteredConnectors.value))
|
||||
}*/
|
||||
MutableLiveData()
|
||||
}
|
||||
}
|
||||
|
||||
val myLocationEnabled: MutableLiveData<Boolean> by lazy {
|
||||
|
||||
Reference in New Issue
Block a user