-
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.
Extensive restructuring, added unofficial Polestar API
- Loading branch information
Showing
54 changed files
with
1,931 additions
and
215 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/de/ixam97/carstatswidget/repository/CarDataInterface.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,42 @@ | ||
package de.ixam97.carstatswidget.repository | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
|
||
abstract class CarDataInterface { | ||
abstract val passwordKey: String | ||
abstract val mailKey: String | ||
abstract val name: String | ||
|
||
// final var status: CarDataStatus = CarDataStatus.NotLoggedIn | ||
// protected set | ||
// final var message: String = "" | ||
// protected set | ||
|
||
var networkStatus: Boolean? = null | ||
protected set | ||
|
||
abstract suspend fun login(apiCredentials: ApiCredentials, context: Context): Boolean | ||
|
||
abstract suspend fun logout(context: Context) | ||
|
||
abstract suspend fun verifyLogin(context: Context): Boolean | ||
|
||
abstract suspend fun getVehicles(context: Context): List<CarDataInfo.CarData>? | ||
|
||
protected fun handleException(e: Exception, tag: String) { | ||
if (e is java.net.UnknownHostException || e is java.net.SocketTimeoutException) { | ||
// status = CarDataStatus.Unavailable | ||
// message = "Network connection error" | ||
Log.e(tag, "Network connection error: ${e.message}") | ||
CarDataRepository.setNetworkError(e.message?:"Unknown error") | ||
} else { | ||
Log.e(tag, e.stackTraceToString()) | ||
} | ||
} | ||
} | ||
|
||
data class ApiCredentials( | ||
val email: String, | ||
val password: String | ||
) |
Oops, something went wrong.