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
abstract class Animal { | |
public void voice(){ | |
System.out.println("unknown"); | |
} | |
} | |
final class Cat { | |
public abstract void voice(){ | |
System.out.println("meow"); | |
} |
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
abstract class Animal { | |
public void voice(){ | |
System.out.println("unknown"); | |
} | |
} | |
final class Cat { | |
public abstract void voice(){ | |
System.out.println("meow"); | |
} |
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 MainFragment : Fragment() { | |
// The dependency isn't final and private | |
@Inject | |
lateinit var sampleDep: SampleDependency | |
override fun onAttach(context: Context) { | |
super.onAttach(context) | |
// Inject dependencies with Dagger 2 | |
} |
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
// Описываем зависимости в констркуторе, они сразу final и private | |
class MainFragment(private val dependency: SampleDependency) : Fragment() |
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
StrictMode.ThreadPolicy.Builder threadPolicyBuilder = | |
new StrictMode.ThreadPolicy.Builder() | |
.detectDiskReads() | |
.detectDiskWrites() | |
.detectDiskReads() | |
.penaltyLog(); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
threadPolicyBuilder.detectResourceMismatches(); | |
} |
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
Version | October 2018 (%) | May 2019(%) | Diff (%) | |
---|---|---|---|---|
2.3 | 0.2 | 0.3 | +0.1 | |
4.0 | 0.3 | 0.3 | 0 | |
4.1 | 1.1 | 1.2 | +0.1 | |
4.2 | 1.5 | 1.5 | 0 | |
4.3 | 0.4 | 0.5 | +0.1 | |
4.4 | 7.6 | 6.9 | -0.7 | |
5.0 | 3.5 | 3 | -0.5 | |
5.1 | 14.4 | 11.5 | -2.9 | |
6.0 | 21.3 | 16.9 | -4.4 |
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
fun asyncOperation(): ListenableFuture<Foo> { | |
return CallbackToFutureAdapter.getFuture { completer: CallbackToFutureAdapter.Resolver<Foo> -> | |
asyncApi.load(object : OnResult { | |
override fun onSuccess(foo: Foo) { | |
completer.set(foo); | |
} | |
override fun onError(failure: Failure) { | |
completer.setException(failure.exception); |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-kapt' | |
android { | |
compileSdkVersion 29 | |
buildToolsVersion "29.0.2" | |
defaultConfig { | |
applicationId "by.kirich1409.sample.jetpackcompose" |
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
@Composable | |
fun Hello(name: String) = MaterialTheme { | |
FlexColumn { | |
inflexible { // Item height will be equal content height | |
TopAppBar<MenuItem>( // App Bar with title | |
title = { Text("Jetpack Compose Sample") } | |
) | |
} | |
expanded(1F) { // occupy whole empty space in the Column | |
Center { // Center content |
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() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { Hello("Jetpack Compose") } | |
} | |
} |
OlderNewer