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
public interface Response { | |
int getHttpCode(); | |
} | |
public final class Success implements Response { | |
private final int httpCode; | |
@NotNull private final String data; | |
public int getHttpCode() { | |
return this.httpCode; |
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
sealed class Response(open val httpCode: Int) | |
data class Success( | |
override val httpCode: Int, | |
val data: String | |
) : Response(httpCode = httpCode) | |
data class Fail( | |
override val httpCode: Int | |
) : Response(httpCode = httpCode) |
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
public abstract class Response { | |
private final int httpCode; | |
public int getHttpCode() { | |
return this.httpCode; | |
} | |
private Response(int httpCode) { | |
this.httpCode = httpCode; | |
} |
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
sealed class Response | |
data class Success( | |
val data: String | |
) : Response() | |
data object Failed : Response() |
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
enum class Response { | |
SUCCESS, | |
FAIL | |
} |
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
sealed interface Response { | |
val httpCode: Int | |
} | |
data class Success( | |
override val httpCode: Int, | |
val data: String | |
) : Response | |
data class Fail( |
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
sealed class Response { | |
abstract val httpCode: Int | |
} | |
data class Success( | |
override val httpCode: Int, | |
val data: String | |
) : Response() |
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 UIKit | |
import SwiftUI // <-- Add SwiftUI import | |
class HelloWorldView: UIView { | |
// UIView code here | |
struct HelloWorldView_Preview: PreviewProvider { // <-- Add the preview definition | |
static var previews: some View { | |
Preview() |
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 UIKit | |
class HelloWorldView: UIView { | |
private lazy var title = createTitle() | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
addSubview(title) | |
} |
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 MainActivity : AppCompatActivity() { | |
private val listener = Manager.Listener { | |
Log.d("memory_leak", "Use largeObject to avoid compiler opti $largeObject") | |
} | |
private var largeObject = (0..4_000).map { | |
Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888) | |
} | |
override fun onCreate(savedInstanceState: Bundle?) { |
NewerOlder