Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Aug 25, 2023
2 parents 5e66482 + 2588227 commit 9562d85
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdk 29
targetSdk 32
versionCode 1
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -38,7 +38,7 @@ publishing {
release(MavenPublication) {
groupId = 'com.fivegmag'
artifactId = 'a5gmscommonlibrary'
version = '1.0.1'
version = '1.0.2'

afterEvaluate {
from components.release
Expand All @@ -62,7 +62,12 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation "androidx.media3:media3-exoplayer:1.0.2"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

//Retrofit
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.fivegmag.a5gmscommonlibrary.eventbus
import androidx.media3.exoplayer.source.MediaLoadData

class DownstreamFormatChangedEvent(val mediaLoadData: MediaLoadData)
83 changes: 83 additions & 0 deletions app/src/main/java/com/fivegmag/a5gmscommonlibrary/helpers/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.fivegmag.a5gmscommonlibrary.helpers

import java.text.SimpleDateFormat
import java.time.Duration
import java.util.Date
import java.util.Random
import java.util.TimeZone
import okhttp3.Headers

class Utils {

fun getCurrentTimestamp(): Long {
return System.currentTimeMillis();
}

fun convertTimestampToXsDateTime(timestampInMillis: Long): String {
// Create a Date object using the provided timestamp
val date = Date(timestampInMillis)

// Create a SimpleDateFormat object to format the date
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
dateFormat.timeZone = TimeZone.getTimeZone("UTC")

// Format the date to xs:datetime string
return dateFormat.format(date)
}

fun getCurrentXsDateTime(): String {
val currentTimestamp = getCurrentTimestamp()

return convertTimestampToXsDateTime(currentTimestamp)
}

fun millisecondsToISO8601(milliseconds: Long): String? {
// Create a Duration object from milliseconds
val duration: Duration = Duration.ofMillis(milliseconds)

// Extract the components from the duration
val years: Long = duration.toDays() / 365
val days: Long = duration.toDays() % 365
val hours: Long = duration.toHours() % 24
val minutes: Long = duration.toMinutes() % 60
val seconds: Long = duration.seconds % 60

// Construct the ISO 8601 period string
return "P" + years + "Y" + days + "D" +
"T" + hours + "H" + minutes + "M" + seconds + "S"
}

fun generateRandomFloat(): Float {
val random = Random()
return random.nextFloat() * 100.0f
}

fun addTrailingSlashIfNeeded(input: String): String {
return if (!input.endsWith("/")) {
"$input/"
} else {
input
}
}

fun hasResponseChanged(
headers: Headers,
previousResponseHeaders: Headers?
): Boolean {
if (previousResponseHeaders == null) {
return true
}
val headersToValidate = arrayOf("last-modified", "etag")

return headersToValidate.all { header ->
hasHeaderChanged(
headers.get(header),
previousResponseHeaders.get(header)
)
}
}

private fun hasHeaderChanged(headerA: String?, headerB: String?): Boolean {
return headerA == null || headerB == null || headerA != headerB
}
}

0 comments on commit 9562d85

Please sign in to comment.