This file contains hidden or 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
| import androidx.compose.runtime.Composable | |
| import androidx.compose.ui.platform.LocalInspectionMode | |
| import androidx.hilt.navigation.compose.hiltViewModel | |
| import androidx.lifecycle.ViewModel | |
| /** | |
| * A Composable function that simplifies the process of providing a ViewModel in both | |
| * runtime and preview environments. | |
| * | |
| * In a standard runtime environment, it uses `hiltViewModel()` to retrieve a |
This file contains hidden or 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
| /** | |
| * Task: increaseLogcatBufferSize | |
| * | |
| * This Gradle task uses the Exec task type to execute an ADB command that increases the | |
| * Android logcat buffer size to 16 megabytes (16M). This is useful when significant logging | |
| * is enabled, ensuring that the log buffer does not truncate your logs during development | |
| * and debugging. | |
| * | |
| * IMPORTANT: | |
| * - Update the adb executable path in the commandLine() call to match your local environment. |
This file contains hidden or 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
| /** | |
| * Checks if the current network is connected to the internet and validated. | |
| * Validation indicates the network is functional (e.g., it can be used for browsing). | |
| * | |
| * @return True if the network is connected, has internet capability, and is validated; false otherwise. | |
| */ | |
| private fun Context.isInternetFunctional(): Boolean { | |
| val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| val network = connectivityManager.activeNetwork | |
| val networkCapabilities = connectivityManager.getNetworkCapabilities(network) |
This file contains hidden or 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
| object JwtHelper { | |
| /** | |
| * Enum class representing JWT algorithms with their corresponding values. | |
| */ | |
| enum class JwtAlgorithm(val value: String) { | |
| ALGORITHM_HS256("HS256"), ALGORITHM_HS384("HS384"), ALGORITHM_HS512("HS512") | |
| } | |
| /** | |
| * Enum class representing HMAC signature algorithms with their corresponding values. |
This file contains hidden or 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
| import androidx.fragment.app.Fragment | |
| import androidx.lifecycle.ViewModel | |
| import dagger.Module | |
| import dagger.Provides | |
| import dagger.hilt.InstallIn | |
| import dagger.hilt.android.components.ViewModelComponent | |
| import dagger.hilt.android.lifecycle.HiltViewModel | |
| import javax.inject.Inject | |
| import javax.inject.Named |
This file contains hidden or 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
| /** | |
| * Executes a coroutine with configurable dispatchers for subscription and observation. | |
| * | |
| * @param subscribeOn The dispatcher context for subscribing to the asynchronous operation (default: Dispatchers.IO). | |
| * @param observeOn The dispatcher context for observing the result (default: Dispatchers.Main). | |
| * @param block A suspend function representing the asynchronous operation to be executed. | |
| * @param onSuccess A suspend function that is invoked with the result of the asynchronous operation when it succeeds. | |
| * @param onError A function that is invoked if the asynchronous operation encounters an error. | |
| */ | |
| fun <T> withCoroutine( |
This file contains hidden or 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
| /** | |
| * Default implementation of [LocaleHelperKt]. | |
| */ | |
| class DefaultLocaleHelper private constructor(context: Context) : BaseLocaleHelper(context) { | |
| companion object { | |
| /* Mark the instance as Volatile*/ | |
| @Volatile | |
| private var instance: LocaleHelperKt? = null | |
| private var LOCK: Any = Any() |
This file contains hidden or 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
| class LoginInterceptor: Interceptor{ | |
| override fun intercept(chain: Interceptor.Chain): Response { | |
| //If requested endpoint matched to targeted endpoint, we will return an mocked response. | |
| if (chain.request().url.toUri().toString().endsWith("fake-login")) { | |
| val responseString = "OUR_JSON_RESPONSE_FROM_ASSET_OR_OTHER_SOURCE" | |
| return chain.proceed(chain.request()) | |
| .newBuilder() | |
| .code(200) | |
| .protocol(Protocol.HTTP_2) | |
| .message(responseString) |
This file contains hidden or 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
| /** | |
| * Add an action which will be invoked when the text is changing. | |
| * | |
| * @return the [EditText.onTextChangeListener] added to the [EditText] | |
| */ | |
| inline fun EditText.doAfterTextChanged( | |
| delay: Long = 500, | |
| crossinline onTextChangedDelayed: (text: String) -> Unit | |
| ) = onTextChangeListener(delay, onTextChangedDelayed) |
This file contains hidden or 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
| sealed class AppFailure { | |
| /** | |
| * Global Failure classes | |
| * These failures will be used across all over the app including Data Layer, Domain Layer, Framework Layer | |
| */ | |
| class GeneralFailure(var message: String, var errorCode: Int? = null) : AppFailure() | |
| class UnauthorizedFailure(var message: String = "Unauthorized", errorCode: Int? = null) : AppFailure() | |
| class LoginFailure(var message: String = "Unable to login", errorCode: Int? = null) : AppFailure() | |
| class ServerFailure(var message: String = "Unable to connect to the server side", errorCode: Int? = null) : AppFailure() | |
| class NoInternetFailure(var message: String = "Device is not connected to the internet", errorCode: Int? = null) : AppFailure() |
NewerOlder