Skip to content

Instantly share code, notes, and snippets.

///////////////////////////////////////////////////////////////////////////
// Row style BasicText
///////////////////////////////////////////////////////////////////////////
@Composable
fun BulletTextRow(
text: String,
modifier: Modifier = Modifier,
style: TextStyle = LocalTextStyle.current,
bulletRadius: Dp = 2.dp,
bulletSpace: Dp = bulletRadius * 2,
@Pluu
Pluu / ColorPicker.kt
Created March 30, 2024 00:51 — forked from KlassenKonstantin/ColorPicker.kt
Color Picker
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
ColorPickerTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
public final class SavedStateHandle {
final Map<String, Object> mRegular;
...
private final SavedStateProvider mSavedStateProvider = new SavedStateProvider() {
@NonNull
public Bundle saveState() {
Set<String> keySet = mRegular.keySet();
ArrayList keys = new ArrayList(keySet.size());
ArrayList value = new ArrayList(keys.size());
...
public final class SavedStateHandle {
static SavedStateHandle createHandle(@Nullable Bundle restoredState,
@Nullable Bundle defaultState) {
...
Map<String, Object> state = new HashMap<>();
if (defaultState != null) {
for (String key : defaultState.keySet()) {
state.put(key, defaultState.get(key));
}
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull String key, @NonNull Class<T> modelClass) {
boolean isAndroidViewModel = AndroidViewModel.class.isAssignableFrom(modelClass);
...
Constructor<T> constructor;
constructor = ... // Define ViewModel Constructor
// Case 1, SavedStateHandleが不要の場合
if (constructor == null) {
return mFactory.create(modelClass);
@MainThread
inline fun <reified VM : ViewModel> ComponentActivity.viewModels(
noinline factoryProducer: (() -> Factory)? = null
): Lazy<VM> {
val factoryPromise = factoryProducer ?: {
defaultViewModelProviderFactory
}
return ViewModelLazy(VM::class, { viewModelStore }, factoryPromise)
}
@NonNull
@Override
public ViewModelProvider.Factory getDefaultViewModelProviderFactory() {
...
mDefaultFactory = new SavedStateViewModelFactory(
requireActivity().getApplication(),
this,
getArguments()); // ◀ Fragmentに渡されたArgumentを代入
}
return mDefaultFactory;
@NonNull
@Override
public ViewModelProvider.Factory getDefaultViewModelProviderFactory() {
...
mDefaultFactory = new SavedStateViewModelFactory(
getApplication(),
this,
getIntent() != null ? getIntent().getExtras() : null); // ◀ Activityに渡されたArgumentを代入
...
return mDefaultFactory;
public class ViewModelProvider {
...
private final Factory mFactory;
private final ViewModelStore mViewModelStore;
// ① Use ViewModelStoreOwner
public ViewModelProvider(@NonNull ViewModelStoreOwner owner) {
this(owner.getViewModelStore(), owner instanceof HasDefaultViewModelProviderFactory
? ((HasDefaultViewModelProviderFactory) owner).getDefaultViewModelProviderFactory()
: NewInstanceFactory.getInstance());
}
@Pluu
Pluu / RxJava-Part3.md
Last active November 24, 2022 04:12
RxJava 3장 ~ 연산자와 변환

RxJava 3장 ~ 연산자와 변환

핵심 연산자: 매핑과 필터링

map

Operator Wiki : Link