Skip to content

Instantly share code, notes, and snippets.

View pandulapeter's full-sized avatar

Pandula Péter pandulapeter

  • Cluj-Napoca
View GitHub Profile
@pandulapeter
pandulapeter / BeagleSetup.kt
Last active April 12, 2024 15:01
Advanced setup instructions for Beagle
// 1. In the project-level build.gradle file
buildscript {
...
ext {
...
beagleVersion = "2.9.4" // Check GitHub (https://github.com/pandulapeter/beagle/releases) / MavenCentral (https://repo1.maven.org/maven2/io/github/pandulapeter/beagle/) for the latest version
beagleUiType = "ui-drawer" // Could also be "ui-activity", "ui-bottom-sheet", "ui-dialog" or "ui-view"
}
}
@pandulapeter
pandulapeter / BeagleExampleListItem.kt
Last active October 9, 2019 04:16
BeagleExample - list item
data class Account(
override val name: String,
val password: String
) : BeagleListItemContract
val testAccounts = listOf(
Account("User 1", "password1"),
Account("User 2", "password2"),
Account("User 3", "password3")
)
@pandulapeter
pandulapeter / BeagleExampleSingleSelectionList.kt
Created October 8, 2019 09:24
Beagle example - SingleSelectionList trick
Trick.SingleSelectionList(
title = "Backend environment",
items = environments,
isInitiallyExpanded = true,
initialSelectionId = preferenceManager.environmentId,
onItemSelectionChanged = { environment -> changeEnvironment(environment.id) }
)
@pandulapeter
pandulapeter / BeagleExampleSimpleList.kt
Last active October 8, 2019 12:06
Beagle example - SimpleList trick
Trick.SimpleList(
id = TEST_ACCOUNTS_MODULE_ID,
title = "Test accounts",
items = testAccounts,
onItemSelected = { account ->
findViewById<EditText>(R.id.username_input).setText(account.name)
findViewById<EditText>(R.id.password_input).setText(account.password)
Beagle.dismiss(this@LoginActivity)
}
)
@pandulapeter
pandulapeter / BeagleExampleNetworkLogList.kt
Created October 8, 2019 05:20
Beagle example - NetworkLogList trick
Trick.NetworkLogList(
baseUrl = NetworkingManager.BASE_URL,
shouldShowHeaders = true,
shouldShowTimestamp = true
)
@pandulapeter
pandulapeter / BeagleExampleHeaderApp.gradle
Last active October 8, 2019 05:12
Beagle example - Header trick build script
android {
defaultConfig {
buildConfigField("String", "BUILD_DATE", "\"${new Date().format("yyyy.MM.dd")}\"")
}
}
@pandulapeter
pandulapeter / BeagleExampleHeader.kt
Created October 8, 2019 05:06
Beagle example - Header trick
Trick.Header(
title = getString(R.string.app_name),
subtitle = "v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})",
text = "Built on ${BuildConfig.BUILD_DATE}"
)
@pandulapeter
pandulapeter / BeagleExampleApplicationClass.kt
Created October 7, 2019 17:35
Beagle example - initializing the library
class YourApplication : Application() {
override fun onCreate() {
super.onCreate()
Beagle.imprint(this)
}
}
@pandulapeter
pandulapeter / BeagleExampleApp.gradle
Last active October 8, 2019 15:33
Beagle example - app level build script
dependencies {
def beagleVersion = "1.1.0"
debugImplementation "com.github.pandulapeter.beagle:beagle:$beagleVersion"
releaseImplementation "com.github.pandulapeter.beagle:beagle-noop:$beagleVersion"
}
@pandulapeter
pandulapeter / BeagleExampleProject.gradle
Last active October 7, 2019 16:50
Beagle example - project level build script
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}