Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Script which handles starting the UI build container, then building the UI inside of it.
# This expects to be run from a bamboo task, hence the $bamboo_X variables. Set these locally if you want to run it locally.
# Call it with no args to start the container
# Call it with 'build' to run the build, test, and upload process
set -euo pipefail
echo "Starting build now"
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "au.com.auspost.app"
minSdkVersion 28
@markchristopherng
markchristopherng / equals.kt
Created August 19, 2019 00:22
Equals method
override fun equals(other: Any?): Boolean {
// same type
if (other == null || other !is Consignment) {
return false
}
// null id
return if (id == null) {
other.id == null
class App : Application() {
val appConfigManager: AppConfigManager by inject()
override fun onCreate() {
super.onCreate()
KTP.openRootScope()
.openSubScope(APPSCOPE)
.installModules(AppModule(this))
class AppModule(val application: Application) : Module() {
init {
val context = application.applicationContext
bind(Application::class.java).toInstance(application)
bind(Context::class.java).toInstance(context)
bind(AppConfigManager::class.java).toInstance(AppConfigManager())
}
}
class PayBillActivity() : BaseActivity(R.layout.activity_pay_bill) {
val payBillManager: IPayBillManager by inject()
override fun onCreate(savedInstanceState: Bundle?) {
KTP.openRootScope()
.openSubScope(APPSCOPE)
.openSubScope(this)
.installModules(module { bind<IPayBillManager>().toClass<PayBillManager>()})
.closeOnDestroy(this)
class CustomerActivity : BaseActivity(R.layout.activity_customer) {
@Inject lateinit var customerManager: CustomerManager
override fun onCreate(savedInstanceState: Bundle?) {
KTP.openRootScope()
.openSubScope(APPSCOPE)
.openSubScope(this)
.supportScopeAnnotation(ActivityScope::class.java)
@Singleton
class CustomerManager @Inject constructor (val customerDao: CustomerDao) {
fun getCustomerDetails(): Single<Customer> {
return customerDao.getCustomerDetails()
}
}
abstract class BaseActivity(@LayoutRes contentLayoutId: Int) : AppCompatActivity(contentLayoutId) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
getScope().supportScopeAnnotation(ActivityScope::class.java)
.installModules(ActivityModule(this))
.closeOnDestroy(this)
.inject(this)
}
class PayBillActivity() : BaseActivity(R.layout.activity_pay_bill) {
val payBillManager: IPayBillManager by inject()
override fun getScope(): Scope {
return super.getScope().installModules(module {
bind<IPayBillDao>().toClass<PayBillDao>()
bind<IPayBillManager>().toClass<PayBillManager>()
})
}