This file contains hidden or 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 class ValueStateFlow<T : Any>( | |
private val store: Value<T>, | |
) : StateFlow<T> { | |
override val value: T get() = store.value | |
override val replayCache: List<T> get() = listOf(store.value) | |
override suspend fun collect(collector: FlowCollector<T>): Nothing { | |
val flow = MutableStateFlow(store.value) | |
val observer: (T) -> Unit = { flow.value = it } |
This file contains hidden or 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
interface MyComponent { | |
val myViewModelFactory: ViewModelFactory<MyViewModel> | |
} |
This file contains hidden or 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
// this is fine | |
class CreateApplicationInteractor { | |
val isApplicationEnabled: Boolean | |
get() = when (BrandConfiguration.brand) { | |
BrandConfiguration.Brand.MY_INTERCOM_FOREIGN -> false | |
else -> true | |
} | |
} |
This file contains hidden or 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
val adapter = ArrayAdapter( | |
requireContext(), | |
R.layout.item_dropdown_country, | |
countryList // List<String> | |
) | |
binding.editTextCountry.setAdapter(adapter) | |
binding.editTextCountry.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id -> | |
binding.editTextPhone.requestFocus() | |
} |
This file contains hidden or 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
// Допустим, у вас есть интерфейс ProjectRepository, его реализация ProjectServerRepository. | |
// И вы хотите забиндить интерфейс к реализации. | |
public class ProjectServerRepository implements ProjectRepository { | |
@Inject | |
public ProjectServerRepository(Context context) {...} | |
} | |
public class MyModule extends Module { |
This file contains hidden or 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 movieCell(listener : (Movie) -> Unit) = adapterDelegateLayoutContainer<Movie, RecyclerItem>(R.layout.item_movie) { | |
itemView.setClickListener { listener.invoke(item) } | |
bind { diffPayloads -> | |
name.text = item.name | |
} | |
} |
This file contains hidden or 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 final class RepositoryModule extends Module { | |
public RepositoryModule(Context context) { | |
SharedPreferences sharedPreferences = context.getSharedPreferences("app.prefs", MODE_PRIVATE); | |
bind(SharedPreferences.class).toInstance(sharedPreferences); | |
bind(UserRepository.class) | |
.to(PrefUserRepository.class) | |
.singleton(); | |
} |
This file contains hidden or 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 final class UserActivity extends AppCompatActivity { | |
@Inject | |
UserRepository userRepository; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
Scope appScope = Toothpick.openScope("APP"); |
This file contains hidden or 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 final class App extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Scope appScope = Toothpick.openScope("APP"); | |
appScope.installModules(new RepositoryModule(getApplicationContext())); | |
} | |
} |
NewerOlder