Skip to content

Instantly share code, notes, and snippets.

View JacquesSmuts's full-sized avatar
🙃
Recovering

Jacques Smuts JacquesSmuts

🙃
Recovering
View GitHub Profile
@JacquesSmuts
JacquesSmuts / build.gradle
Last active November 2, 2021 17:50
Determining versionCode based on CircleCI build number
android {
defaultConfig {
versionName "1.9.1"
versionCode getBuildVersion() as int
}
}
// Don't name this getVersionCode() or things will break
static def getBuildVersion() {
def version = 123
@JacquesSmuts
JacquesSmuts / build.gradle
Last active December 26, 2018 08:12
Deploying to track based on Git Branch
// Deployment
play {
track = getDeploymentTrack()
serviceAccountCredentials = file(System.getenv("PRIVATE_KEY") ?: "deployment_private_key.json")
defaultToAppBundles = true
resolutionStrategy = "ignore"
}
// The deployment track is based on the branch.
static def getDeploymentTrack() {
@JacquesSmuts
JacquesSmuts / config1.yml
Last active December 26, 2018 08:16
CircleCI config that builds, tests and deploys
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-25-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
@JacquesSmuts
JacquesSmuts / config2.yml
Last active December 26, 2018 07:06
CircleCI workflow that runs config1.yml
workflows:
version: 2
build-and-deploy:
jobs:
- build
- tests:
requires:
- build
- deploy:
@JacquesSmuts
JacquesSmuts / config.yml
Last active December 26, 2018 08:31
snippet of jobs with deploy_stage and deploy_live running based on branch
version: 2
jobs:
deploy_staging:
working_directory: ~/code
docker:
- image: circleci/android:api-25-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
@Entity(tableName = "UserTable")
internal data class User(
@PrimaryKey val id: String,
val name: String,
val surname: String,
val birthday: Long
)
dependency {
implementation "androidx.room:room-runtime:$roomVersion
kapt "androidx.room:room-compiler:$roomVersion"
}
// In your shared domain/core module
data class User(
val id: String,
val name: String,
val surname: String,
val age: Int
)
// In your database module ONLY
@Entity(tableName = "UserTable")
class UserRepository(private val database: DeviceDatabase) {
val liveUsers: LiveData<List<User>> = Transformations.map(database.userDao().liveUsers) {
it.map {
it.toUser()
}
}
}
interface RetroService
interface GitHubService: RetroService {
@GET("users/{user}/repos")
fun listGitHubRepos(@Path("user") user: String): List<GitHubRepo>
}
interface AwsCodeCommitService: RetroService {
@GET("ListRepositories")
fun listAwsRepos(): List<AwsRepo>