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
com.yourappname | |
│ | |
├── data | |
│ ├── model | |
│ ├── repository | |
│ ├── network | |
│ └── database | |
│ | |
├── ui | |
│ ├── activities |
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
@Suppress("DSL_SCOPE_VIOLATION") | |
plugins { | |
alias(libs.plugins.android.application) | |
alias(libs.plugins.kotlin.android) | |
alias(libs.plugins.kotlin.kapt) | |
alias(libs.plugins.hilt.gradle) | |
alias(libs.plugins.ksp) | |
} | |
android { |
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
fun hasNetwork(context: Context): Boolean { | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val nw = connectivityManager.activeNetwork ?: return false | |
val actNw = connectivityManager.getNetworkCapabilities(nw) ?: return false | |
return when { | |
actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true | |
actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true | |
actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true | |
actNw.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) -> true | |
else -> false |
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
import android.content.* | |
import android.net.Uri | |
import android.provider.Settings | |
class ActivityHelper { | |
companion object { | |
@JvmStatic |
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
import org.jetbrains.annotations.NonNls | |
import timber.log.Timber | |
import java.io.File | |
class Logger { | |
private lateinit var cacheDir: File | |
companion object { |
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
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf | |
insert_final_newline = false | |
indent_style = space | |
indent_size = 4 | |
max_line_length = 120 |
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
// ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } catalog ktlint = "12.0.3" | |
ktlint { | |
version.set("1.0.1") | |
android.set(true) | |
debug.set(true) | |
verbose.set(true) | |
outputToConsole.set(true) | |
outputColorName.set("RED") | |
ignoreFailures.set(false) | |
enableExperimentalRules.set(true) |
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
import android.Manifest | |
object Permissions { | |
const val CAMERA = Manifest.permission.CAMERA | |
const val READ_EXTERNAL_STORAGE = Manifest.permission.READ_EXTERNAL_STORAGE | |
const val WRITE_EXTERNAL_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE | |
} |
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
import android.os.Bundle | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.viewbinding.ViewBinding | |
import dagger.hilt.android.AndroidEntryPoint | |
import kotlinx.coroutines.* | |
import javax.inject.Inject | |
@AndroidEntryPoint | |
abstract class BaseActivity<T : ViewBinding> : AppCompatActivity(), BaseView { |
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
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val networkInfo = connectivityManager.activeNetworkInfo | |
return networkInfo != null && networkInfo.isConnected | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val network = connectivityManager.activeNetwork | |
val capabilities = connectivityManager.getNetworkCapabilities(network) | |
return capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true | |
fun isInternetAvailable(): Boolean { |
NewerOlder