-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from swapnil-musale/development
Android App Release V1.0.5
- Loading branch information
Showing
21 changed files
with
168 additions
and
84 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
deploymentTargetDropDown.xml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.devx.data | ||
|
||
import com.devx.data.model.JokeResponse | ||
import com.devx.data.model.JokeResponseDto | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
|
||
interface JokeApi { | ||
|
||
@GET("joke/Any") | ||
suspend fun getJoke(): Response<JokeResponse> | ||
suspend fun getJoke(): Response<JokeResponseDto> | ||
} |
This file was deleted.
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
24 changes: 6 additions & 18 deletions
24
data/src/main/java/com/devx/data/repository/JokeRepositoryImpl.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 |
---|---|---|
@@ -1,32 +1,20 @@ | ||
package com.devx.data.repository | ||
|
||
import com.devx.data.JokeApi | ||
import com.devx.data.mapper.toDto | ||
import com.devx.data.model.JokeCategoryData | ||
import com.devx.data.util.safeApiCall | ||
import com.devx.domain.model.JokeResponse | ||
import com.devx.domain.repository.JokeRepository | ||
import com.devx.domain.util.NetworkResponse | ||
import javax.inject.Inject | ||
|
||
class JokeRepositoryImpl @Inject constructor(private val jokeApi: JokeApi) : JokeRepository { | ||
|
||
override suspend fun getJoke(): JokeResponse { | ||
return try { | ||
val response = jokeApi.getJoke() | ||
response.body().toDto() | ||
} catch (exception: Exception) { | ||
JokeResponse( | ||
joke = "", | ||
setUp = "", | ||
delivery = "", | ||
category = "", | ||
type = "", | ||
error = true, | ||
message = exception.message, | ||
) | ||
} | ||
override suspend fun getJoke(): NetworkResponse<JokeResponse> { | ||
return safeApiCall { jokeApi.getJoke() } | ||
} | ||
|
||
override fun getJokeCategories(): ArrayList<String> { | ||
return JokeCategoryData.jokeCategories | ||
override fun getJokeCategories(): NetworkResponse<List<String>> { | ||
return NetworkResponse.Success(data = JokeCategoryData.jokeCategories) | ||
} | ||
} |
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,22 @@ | ||
package com.devx.data.util | ||
|
||
import com.devx.domain.util.Mapper | ||
import com.devx.domain.util.NetworkResponse | ||
import retrofit2.HttpException | ||
import retrofit2.Response | ||
|
||
suspend fun <R : Mapper<T>, T : Any> safeApiCall(execute: suspend () -> Response<R>): NetworkResponse<T> { | ||
return try { | ||
val response = execute() | ||
val body = response.body() | ||
if (response.isSuccessful && body != null) { | ||
NetworkResponse.Success(data = body.mapToDomain()) | ||
} else { | ||
NetworkResponse.Error(errorMessage = response.message()) | ||
} | ||
} catch (exception: HttpException) { | ||
NetworkResponse.Error(errorMessage = exception.localizedMessage) | ||
} catch (throwable: Throwable) { | ||
NetworkResponse.Exception(throwable = throwable) | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
App Performance Improvement |
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
5 changes: 3 additions & 2 deletions
5
domain/src/main/java/com/devx/domain/repository/JokeRepository.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package com.devx.domain.repository | ||
|
||
import com.devx.domain.model.JokeResponse | ||
import com.devx.domain.util.NetworkResponse | ||
|
||
interface JokeRepository { | ||
suspend fun getJoke(): JokeResponse | ||
fun getJokeCategories(): ArrayList<String> | ||
suspend fun getJoke(): NetworkResponse<JokeResponse> | ||
fun getJokeCategories(): NetworkResponse<List<String>> | ||
} |
3 changes: 2 additions & 1 deletion
3
domain/src/main/java/com/devx/domain/useCase/GetJokeCategoriesUseCase.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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.devx.domain.useCase | ||
|
||
import com.devx.domain.repository.JokeRepository | ||
import com.devx.domain.util.NetworkResponse | ||
import javax.inject.Inject | ||
|
||
class GetJokeCategoriesUseCase @Inject constructor(private val jokeRepository: JokeRepository) { | ||
operator fun invoke(): ArrayList<String> { | ||
operator fun invoke(): NetworkResponse<List<String>> { | ||
return jokeRepository.getJokeCategories() | ||
} | ||
} |
Oops, something went wrong.