-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some animation. Corrected ui.Simple Firebase with Room Sync works.
- Loading branch information
1 parent
afe4b4f
commit 1ba06d4
Showing
54 changed files
with
1,092 additions
and
220 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object DataStore { | ||
private const val dataStoreVersion = "1.0.0" | ||
const val dataStore = "androidx.datastore:datastore-preferences:$dataStoreVersion" | ||
} |
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,4 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
</manifest> |
8 changes: 8 additions & 0 deletions
8
core_data/src/main/java/com/eltescode/core_data/utils/exception/CallOrThrow.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.eltescode.core_data.utils.exception | ||
|
||
suspend fun <T> callOrThrow( | ||
errorWrapper: ErrorWrapper, | ||
apiCall: suspend () -> T | ||
): T { | ||
return runCatching { apiCall() }.getOrElse { throw errorWrapper.wrap(it) } | ||
} |
5 changes: 5 additions & 0 deletions
5
core_data/src/main/java/com/eltescode/core_data/utils/exception/ErrorWrapper.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.eltescode.core_data.utils.exception | ||
|
||
interface ErrorWrapper { | ||
fun wrap(throwable: Throwable): Throwable | ||
} |
30 changes: 30 additions & 0 deletions
30
core_data/src/main/java/com/eltescode/core_data/utils/exception/ErrorWrapperImpl.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.eltescode.core_data.utils.exception | ||
|
||
import retrofit2.HttpException | ||
|
||
|
||
class ErrorWrapperImpl : ErrorWrapper { | ||
override fun wrap(throwable: Throwable): Throwable { | ||
return when (throwable) { | ||
is HttpException -> { | ||
wrapServerException(throwable) | ||
} | ||
|
||
else -> throwable | ||
} | ||
} | ||
|
||
private fun wrapServerException(httpException: HttpException): Throwable { | ||
return with(httpException) { | ||
when (httpException.code()) { | ||
500 -> ServerException.Internal(message) | ||
400 -> ServerException.BadRequest(message) | ||
401 -> ServerException.Unauthorized(message) | ||
402 -> ServerException.PaymentRequired(message) | ||
403 -> ServerException.Forbidden(message) | ||
404 -> ServerException.NotFound(message) | ||
else -> ServerException.Unknown(message) | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
core_data/src/main/java/com/eltescode/core_data/utils/exception/ServerException.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.eltescode.core_data.utils.exception | ||
|
||
sealed class ServerException(message: String?) : Throwable(message) { | ||
class Internal(message: String?) : ServerException(message) | ||
class NotFound(message: String?) : ServerException(message) | ||
class BadRequest(message: String?) : ServerException(message) | ||
class Unauthorized(message: String?) : ServerException(message) | ||
class PaymentRequired(message: String?) : ServerException(message) | ||
class Forbidden(message: String?) : ServerException(message) | ||
class Unknown(message: String?) : ServerException(message) | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
core_data/src/main/java/com/eltescode/core_data/utils/network/NetworkStateProvider.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.eltescode.core_data.utils.network | ||
|
||
interface NetworkStateProvider { | ||
fun isNetworkAvailable(): Boolean | ||
} |
20 changes: 20 additions & 0 deletions
20
core_data/src/main/java/com/eltescode/core_data/utils/network/NetworkStateProviderImpl.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.eltescode.core_data.utils.network | ||
|
||
import android.net.ConnectivityManager | ||
import android.net.NetworkCapabilities | ||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
|
||
class NetworkStateProviderImpl(private val connectivityManager: ConnectivityManager) : | ||
NetworkStateProvider { | ||
@RequiresApi(Build.VERSION_CODES.M) | ||
override fun isNetworkAvailable(): Boolean { | ||
val capabilities = | ||
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) | ||
?: return false | ||
|
||
return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) | ||
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) | ||
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) | ||
} | ||
} |
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
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
Oops, something went wrong.