Operator Wiki : Link
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
/////////////////////////////////////////////////////////////////////////// | |
// Row style BasicText | |
/////////////////////////////////////////////////////////////////////////// | |
@Composable | |
fun BulletTextRow( | |
text: String, | |
modifier: Modifier = Modifier, | |
style: TextStyle = LocalTextStyle.current, | |
bulletRadius: Dp = 2.dp, | |
bulletSpace: Dp = bulletRadius * 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
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 | |
) { |
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 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()); | |
... |
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 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)); | |
} | |
} |
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
@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); |
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
@MainThread | |
inline fun <reified VM : ViewModel> ComponentActivity.viewModels( | |
noinline factoryProducer: (() -> Factory)? = null | |
): Lazy<VM> { | |
val factoryPromise = factoryProducer ?: { | |
defaultViewModelProviderFactory | |
} | |
return ViewModelLazy(VM::class, { viewModelStore }, factoryPromise) | |
} |
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
@NonNull | |
@Override | |
public ViewModelProvider.Factory getDefaultViewModelProviderFactory() { | |
... | |
mDefaultFactory = new SavedStateViewModelFactory( | |
requireActivity().getApplication(), | |
this, | |
getArguments()); // ◀ Fragmentに渡されたArgumentを代入 | |
} | |
return mDefaultFactory; |
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
@NonNull | |
@Override | |
public ViewModelProvider.Factory getDefaultViewModelProviderFactory() { | |
... | |
mDefaultFactory = new SavedStateViewModelFactory( | |
getApplication(), | |
this, | |
getIntent() != null ? getIntent().getExtras() : null); // ◀ Activityに渡されたArgumentを代入 | |
... | |
return mDefaultFactory; |
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 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()); | |
} |
NewerOlder