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
class CustomView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle | |
) : AppCompatEditText(context, attrs, defStyleAttr) |
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
GsonBuilder() | |
.registerTypeAdapter(DateTime::class.java, DateTimeTypeConverter()) | |
.registerTypeAdapterFactory(CustomTypeAdapterFactory()) | |
.create() |
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
GsonBuilder() | |
.registerTypeAdapter(DateTime::class.java, DateTimeTypeConverter()) | |
.registerTypeAdapterFactory(KotlinReflectiveTypeAdapterFactory.create(true)) | |
.registerTypeAdapterFactory(CustomTypeAdapterFactory()) | |
.create() |
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
private final ObjectConstructor<T> constructor; | |
@Override | |
public T read(JsonReader in) throws IOException { | |
... | |
T instance = constructor.construct(); | |
... | |
in.beginObject(); | |
while (in.hasNext()) { | |
String name = in.nextName(); |
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
data class SimpleModel( | |
val hello: String, | |
val world: Int | |
) { | |
val secondHello: String = hello | |
val secondWorld: Int | |
init { | |
secondWorld = world | |
} |
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
data class SimpleModel( | |
val hello: String, | |
val world: Int | |
) |
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
class TestModel( | |
val required: Any, | |
val nonnull: Any = Any(), | |
val nullable: Any? = null | |
) { | |
constructor( | |
required: Any, | |
nonnull: Any | |
) : this(required, nonnull, null) |
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
data class TestModel @JvmOverloads constructor( | |
val requiredValue: Any, | |
val nonnullValue: Any = Any(), | |
val nullableValue: Any? = null | |
) { | |
fun newBuilder(): Builder = Builder(this) | |
class Builder() { | |
lateinit var required: Any | |
var nonnull: Any = Any() |
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
data class TestModel @JvmOverloads constructor( | |
val required: Any, | |
val nonnull: Any = Any(), | |
val nullable: Any? = null | |
) |
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
class CustomView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0, | |
defStyleRes: Int = 0 | |
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) { | |
init { | |
orientation = VERTICAL | |
inflate(context, R.layout.custom_view, this) | |
} |
NewerOlder