Set date format according to api version.
This commit is contained in:
parent
626c9e2797
commit
5b70ae138e
@ -92,6 +92,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
private var displayUnreadCount = false
|
||||
private var displayAllCount = false
|
||||
private var fullHeightCards: Boolean = false
|
||||
private var apiVersionMajor: Int = 0
|
||||
private var itemsNumber: Int = 200
|
||||
private var elementsShown: Int = 0
|
||||
private var maybeTagFilter: Tag? = null
|
||||
@ -108,7 +109,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
private var periodicRefresh = false
|
||||
private var refreshMinutes: Long = 360L
|
||||
private var refreshWhenChargingOnly = false
|
||||
private val dateTimeFormatter = "yyyy-MM-dd HH:mm:ss"
|
||||
private var dateTimeFormatter = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
private lateinit var tabNewBadge: TextBadgeItem
|
||||
private lateinit var tabArchiveBadge: TextBadgeItem
|
||||
@ -195,6 +196,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
|
||||
handleSharedPrefs()
|
||||
|
||||
getApiMajorVersion()
|
||||
|
||||
if (apiVersionMajor > 2) {
|
||||
dateTimeFormatter = "yyyy-MM-dd'T'HH:mm:ssXXX"
|
||||
}
|
||||
|
||||
getElementsAccordingToTab()
|
||||
}
|
||||
|
||||
@ -412,6 +419,19 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getApiMajorVersion() {
|
||||
api.apiVersion.enqueue(object : Callback<ApiVersion> {
|
||||
override fun onFailure(call: Call<ApiVersion>, t: Throwable) {
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<ApiVersion>, response: Response<ApiVersion>) {
|
||||
val version = response.body() as ApiVersion
|
||||
apiVersionMajor = version.getApiMajorVersion()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
customTabActivityHelper.unbindCustomTabsService(this)
|
||||
|
@ -215,6 +215,9 @@ class SelfossApi(
|
||||
fun update(): Call<String> =
|
||||
service.update(userName, password)
|
||||
|
||||
val apiVersion: Call<ApiVersion>
|
||||
get() = service.version()
|
||||
|
||||
val sources: Call<List<Source>>
|
||||
get() = service.sources(userName, password)
|
||||
|
||||
|
@ -48,6 +48,19 @@ data class Spout(
|
||||
@SerializedName("description") val description: String
|
||||
)
|
||||
|
||||
data class ApiVersion(
|
||||
@SerializedName("version") val version: String,
|
||||
@SerializedName("apiversion") val apiversion: String
|
||||
) {
|
||||
fun getApiMajorVersion() : Int {
|
||||
var versionNumber = 0
|
||||
if (apiversion != null) {
|
||||
versionNumber = apiversion.substringBefore(".").toInt()
|
||||
}
|
||||
return versionNumber
|
||||
}
|
||||
}
|
||||
|
||||
data class Source(
|
||||
@SerializedName("id") val id: String,
|
||||
@SerializedName("title") val title: String,
|
||||
|
@ -103,6 +103,9 @@ internal interface SelfossService {
|
||||
@Query("password") password: String
|
||||
): Call<List<Source>>
|
||||
|
||||
@GET("api/about")
|
||||
fun version(): Call<ApiVersion>
|
||||
|
||||
@DELETE("source/{id}")
|
||||
fun deleteSource(
|
||||
@Path("id") id: String,
|
||||
|
Loading…
Reference in New Issue
Block a user