Skip to content

Commit 9562d85

Browse files
committed
Merge remote-tracking branch 'origin/development'
2 parents 5e66482 + 2588227 commit 9562d85

File tree

5 files changed

+96
-4
lines changed

5 files changed

+96
-4
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdk 29
1414
targetSdk 32
1515
versionCode 1
16-
versionName "1.0.1"
16+
versionName "1.0.2"
1717

1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1919
}
@@ -38,7 +38,7 @@ publishing {
3838
release(MavenPublication) {
3939
groupId = 'com.fivegmag'
4040
artifactId = 'a5gmscommonlibrary'
41-
version = '1.0.1'
41+
version = '1.0.2'
4242

4343
afterEvaluate {
4444
from components.release
@@ -62,7 +62,12 @@ dependencies {
6262
implementation 'androidx.core:core-ktx:1.7.0'
6363
implementation 'androidx.appcompat:appcompat:1.6.1'
6464
implementation 'com.google.android.material:material:1.8.0'
65+
implementation "androidx.media3:media3-exoplayer:1.0.2"
6566
testImplementation 'junit:junit:4.13.2'
6667
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
6768
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
69+
70+
//Retrofit
71+
def retrofit_version = "2.9.0"
72+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
6873
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.fivegmag.a5gmscommonlibrary.eventbus
2+
import androidx.media3.exoplayer.source.MediaLoadData
3+
4+
class DownstreamFormatChangedEvent(val mediaLoadData: MediaLoadData)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.fivegmag.a5gmscommonlibrary.helpers
2+
3+
import java.text.SimpleDateFormat
4+
import java.time.Duration
5+
import java.util.Date
6+
import java.util.Random
7+
import java.util.TimeZone
8+
import okhttp3.Headers
9+
10+
class Utils {
11+
12+
fun getCurrentTimestamp(): Long {
13+
return System.currentTimeMillis();
14+
}
15+
16+
fun convertTimestampToXsDateTime(timestampInMillis: Long): String {
17+
// Create a Date object using the provided timestamp
18+
val date = Date(timestampInMillis)
19+
20+
// Create a SimpleDateFormat object to format the date
21+
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
22+
dateFormat.timeZone = TimeZone.getTimeZone("UTC")
23+
24+
// Format the date to xs:datetime string
25+
return dateFormat.format(date)
26+
}
27+
28+
fun getCurrentXsDateTime(): String {
29+
val currentTimestamp = getCurrentTimestamp()
30+
31+
return convertTimestampToXsDateTime(currentTimestamp)
32+
}
33+
34+
fun millisecondsToISO8601(milliseconds: Long): String? {
35+
// Create a Duration object from milliseconds
36+
val duration: Duration = Duration.ofMillis(milliseconds)
37+
38+
// Extract the components from the duration
39+
val years: Long = duration.toDays() / 365
40+
val days: Long = duration.toDays() % 365
41+
val hours: Long = duration.toHours() % 24
42+
val minutes: Long = duration.toMinutes() % 60
43+
val seconds: Long = duration.seconds % 60
44+
45+
// Construct the ISO 8601 period string
46+
return "P" + years + "Y" + days + "D" +
47+
"T" + hours + "H" + minutes + "M" + seconds + "S"
48+
}
49+
50+
fun generateRandomFloat(): Float {
51+
val random = Random()
52+
return random.nextFloat() * 100.0f
53+
}
54+
55+
fun addTrailingSlashIfNeeded(input: String): String {
56+
return if (!input.endsWith("/")) {
57+
"$input/"
58+
} else {
59+
input
60+
}
61+
}
62+
63+
fun hasResponseChanged(
64+
headers: Headers,
65+
previousResponseHeaders: Headers?
66+
): Boolean {
67+
if (previousResponseHeaders == null) {
68+
return true
69+
}
70+
val headersToValidate = arrayOf("last-modified", "etag")
71+
72+
return headersToValidate.all { header ->
73+
hasHeaderChanged(
74+
headers.get(header),
75+
previousResponseHeaders.get(header)
76+
)
77+
}
78+
}
79+
80+
private fun hasHeaderChanged(headerA: String?, headerB: String?): Boolean {
81+
return headerA == null || headerB == null || headerA != headerB
82+
}
83+
}

0 commit comments

Comments
 (0)