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 SomeDetailsViewModel @AssistedInject constructor( | |
@Assisted private val code: String, | |
@Assisted private val type: SomeType, | |
private val someRepository: SomeRepository, | |
) : ViewModel() { | |
@AssistedFactory | |
interface SomeDetailsViewModelAssistedFactory { | |
fun create(code: String, type: SomeType): SomeDetailsViewModel | |
} | |
} |
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
setContent { | |
val animationDurationMs = 500 | |
val messageDisplayDurationMs = 1000L | |
var currentMessageNum by remember { mutableStateOf(0) } | |
//----------This part of the code can be easily moved to the presentation layer and exposed as flow--------- | |
// And then the currentMessageNum will look like: val currentMessageNum by state.messages.collectAsStateWithLifecycle() | |
var messageCounter by remember { mutableStateOf(0) } | |
val messagesQueue = remember { Channel<Int>(capacity = Channel.UNLIMITED) } |
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
@AndroidEntryPoint | |
class SomeFragment : Fragment(R.layout.fragment_some) { | |
companion object { | |
fun newInstance(someId: String): SomeFragment { | |
val instance = SomeFragment() | |
instance.arguments = bundleOf( | |
SomeViewModel.KEY_SOME_ID to someId | |
) | |
return instance |
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 (C) 2018 Fernando Cejas 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
class TService : Service() { | |
companion object { | |
fun start(context: Context, id: Int) { | |
val intent = Intent(context, TService::class.java) | |
intent.putExtra("id", id) | |
context.startService(intent) | |
} | |
} |
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
inline fun <reified T : ViewModel> AppCompatActivity.getViewModel(): T { | |
return ViewModelProviders.of(this)[T::class.java] | |
} | |
inline fun <reified T : ViewModel> AppCompatActivity.withViewModel(body: T.() -> Unit): T { | |
val vm = getViewModel<T>() | |
vm.body() | |
return vm | |
} |
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 java.util.* | |
import kotlin.math.pow | |
import kotlin.math.sqrt | |
private const val START = 'S' | |
private const val END = 'X' | |
private const val OBSTACLE = 'B' | |
private const val PATH = '*' | |
private const val STRAIGHT_STEP = 1f | |
private const val DIAGONAL_STEP = 1.5f |
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 test(action:() -> Unit) { | |
println("start test") | |
action() | |
println("end test") | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Copyright 2016 Google Inc. | |
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 |
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 class RingViewTransition extends Transition { | |
... | |
private void captureValues(RingView view, TransitionValues transitionValues) { | |
Bundle extraData = (Bundle)transitionValues.view.getTag(R.id.tag_transition_extra_properties); | |
if (extraData != null) { | |
transitionValues.values.put(PROPNAME_COLOR, | |
extraData.getInt(PROPNAME_COLOR, view.getColor())); | |
transitionValues.values.put(PROPNAME_INNER_RADIUS, | |
extraData.getFloat(PROPNAME_INNER_RADIUS, view.getInnerCircleRadius())); | |
transitionValues.values.put(PROPNAME_OUTER_RADIUS, |
NewerOlder