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
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
var name: String by FormatDelegate(name) | |
var lastname: String by FormatDelegate(lastname) | |
var updateCount = 0 | |
} |
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
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class FormatDelegate : ReadWriteProperty<Any?, String> { | |
private var formattedString: String = "" | |
override fun getValue( | |
thisRef: Any?, | |
property: KProperty<*> | |
): String { |
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
/* | |
* Copyright 2021 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, var lastname: String) { | |
var name: String = name | |
set(value) { | |
field = value.toLowerCase().capitalize() | |
updateCount++ | |
} | |
var updateCount = 0 |
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
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
var name: String = name | |
set(value) { | |
field = value.toLowerCase().capitalize() | |
updateCount++ | |
} | |
var lastname: String = lastname |
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 com.android.build.api.variant.ApplicationAndroidComponentsExtension | |
import org.gradle.api.Plugin | |
import org.gradle.api.Project | |
class CustomPlugin: Plugin<Project> { | |
override fun apply(project: Project) { | |
project.tasks.register("hello"){ task-> | |
task.doLast { | |
println("Hello " + project.parent?.name) | |
} |
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
package com.example.background.workers | |
import android.content.Context | |
import android.os.SystemClock.sleep | |
import androidx.work.Worker | |
import androidx.work.WorkerParameters | |
class DummyWorker (ctx: Context, params: WorkerParameters) : Worker(ctx, params) { | |
override fun doWork(): Result { |
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
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
val fullname: String by lazy() { | |
name + lastname | |
} | |
//... | |
} |
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
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
@NotNull | |
private final Lazy fullname$delegate; |
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
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
this.fullname$delegate = LazyKt.lazy((Function0)(new Function0() { | |
@NotNull | |
public final String invoke() { | |
return name + lastname; | |
} | |
})); |
NewerOlder