actions java 11 -> 17 & fixed parent job is cancelling message

This commit is contained in:
LagradOst 2023-07-19 18:47:22 +02:00
parent 9755bbacb9
commit da6577e587
6 changed files with 74 additions and 62 deletions

View file

@ -32,10 +32,10 @@ jobs:
private_key: ${{ secrets.GH_APP_KEY }} private_key: ${{ secrets.GH_APP_KEY }}
repository: "recloudstream/cloudstream-archive" repository: "recloudstream/cloudstream-archive"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up JDK 11 - name: Set up JDK 17
uses: actions/setup-java@v2 uses: actions/setup-java@v2
with: with:
java-version: '11' java-version: '17'
distribution: 'adopt' distribution: 'adopt'
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew

View file

@ -42,10 +42,10 @@ jobs:
cd $GITHUB_WORKSPACE/dokka/ cd $GITHUB_WORKSPACE/dokka/
rm -rf "./-cloudstream" rm -rf "./-cloudstream"
- name: Setup JDK 11 - name: Setup JDK 17
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 17
- name: Setup Android SDK - name: Setup Android SDK
uses: android-actions/setup-android@v2 uses: android-actions/setup-android@v2

View file

@ -24,10 +24,10 @@ jobs:
private_key: ${{ secrets.GH_APP_KEY }} private_key: ${{ secrets.GH_APP_KEY }}
repository: "recloudstream/secrets" repository: "recloudstream/secrets"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up JDK 11 - name: Set up JDK 17
uses: actions/setup-java@v2 uses: actions/setup-java@v2
with: with:
java-version: '11' java-version: '17'
distribution: 'adopt' distribution: 'adopt'
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew

View file

@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up JDK 11 - name: Set up JDK 17
uses: actions/setup-java@v2 uses: actions/setup-java@v2
with: with:
java-version: '11' java-version: '17'
distribution: 'adopt' distribution: 'adopt'
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew

View file

@ -129,19 +129,14 @@ fun CoroutineScope.launchSafe(
return this.launch(context, start, obj) return this.launch(context, start, obj)
} }
suspend fun <T> safeApiCall( fun<T> throwAbleToResource(
apiCall: suspend () -> T, throwable: Throwable
): Resource<T> { ): Resource<T> {
return withContext(Dispatchers.IO) { return when (throwable) {
try {
Resource.Success(apiCall.invoke())
} catch (throwable: Throwable) {
logError(throwable)
when (throwable) {
is NullPointerException -> { is NullPointerException -> {
for (line in throwable.stackTrace) { for (line in throwable.stackTrace) {
if (line?.fileName?.endsWith("provider.kt", ignoreCase = true) == true) { if (line?.fileName?.endsWith("provider.kt", ignoreCase = true) == true) {
return@withContext Resource.Failure( return Resource.Failure(
false, false,
null, null,
null, null,
@ -168,7 +163,7 @@ suspend fun <T> safeApiCall(
) )
} }
is UnknownHostException -> { is UnknownHostException -> {
Resource.Failure(true, null, null, "Cannot connect to server, try again later.") Resource.Failure(true, null, null, "Cannot connect to server, try again later.\n${throwable.message}")
} }
is ErrorLoadingException -> { is ErrorLoadingException -> {
Resource.Failure( Resource.Failure(
@ -189,8 +184,24 @@ suspend fun <T> safeApiCall(
(throwable.message ?: "SSLHandshakeException") + "\nTry a VPN or DNS." (throwable.message ?: "SSLHandshakeException") + "\nTry a VPN or DNS."
) )
} }
is CancellationException -> {
throwable.cause?.let {
throwAbleToResource(it)
} ?: safeFail(throwable)
}
else -> safeFail(throwable) else -> safeFail(throwable)
} }
}
suspend fun <T> safeApiCall(
apiCall: suspend () -> T,
): Resource<T> {
return withContext(Dispatchers.IO) {
try {
Resource.Success(apiCall.invoke())
} catch (throwable: Throwable) {
logError(throwable)
throwAbleToResource(throwable)
} }
} }
} }

View file

@ -370,6 +370,7 @@ class HomeViewModel : ViewModel() {
else -> Unit else -> Unit
} }
onGoingLoad = null
} }
fun click(callback: SearchClickCallback) { fun click(callback: SearchClickCallback) {