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
# gradlew alias | |
alias gw=./gradlew |
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 function that aims to help the single event handing. | |
* Use it only for SideEffect event (one shot) and not for handling UI state changes. | |
* | |
* @param sideEffectFlow Flow | |
* @param lifeCycleState default [Lifecycle.State.STARTED] | |
* @param collector | |
*/ | |
@Composable | |
fun <T : Any> SingleEventEffect( |
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
/** | |
* Change shadow color and style | |
* @param color shadow color | |
* @param alpha shadow alpha | |
* @param borderRadius shadow border radius | |
* @param shadowRadius shadow size | |
* @param offsetX X offset | |
* @param offsetY Y offset | |
*/ | |
@RequiresApi(Build.VERSION_CODES.P) |
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
@Override | |
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { | |
switch (requestCode) { | |
case REQUEST_CODE_PERMISSIONS: | |
boolean userAllowed = true; | |
for (final int result : grantResults) { | |
userAllowed &= result == PackageManager.PERMISSION_GRANTED; | |
} | |
if (userAllowed) { | |
start(); |
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
@ViewModelScoped | |
class GithubStateMachine @Inject constructor( | |
private val githubRepository: GithubRepository | |
) : FlowReduxStateMachine<GithubState, GithubAction>( | |
initialState = GithubState.ContentState(owner = "", repositories = emptyList()) | |
) { | |
init { | |
spec { | |
// spec | |
} |
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
Column { | |
Row { | |
TextField( | |
placeholder = { Text(text = "Owner") }, | |
value = contentState.owner, onValueChange = { /* On type */ } | |
) | |
Button( | |
content = { Text(text = "OK") }, | |
onClick = { /* Confirm */ } | |
) |
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
@Test | |
fun `Test confirm upon a failure`() = coroutineTestRule.scope.runTest { | |
// Given | |
coEvery { githubRepository.repositoryByOwner(any()) } returns Either.Left(AppError.Network) | |
// When / Then | |
stateMachine.state.test { | |
stateMachine.dispatch(GithubAction.TypeOwner("mcatta")) | |
stateMachine.dispatch(GithubAction.Confirm) |
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
@Test | |
fun `Test typing`() = coroutineTestRule.scope.runTest { | |
// When / Then | |
stateMachine.state.test { | |
stateMachine.dispatch(GithubAction.TypeOwner("mcatta")) | |
assertEquals("", (awaitItem() as GithubState.ContentState).owner) | |
assertEquals("mcatta", (awaitItem() as GithubState.ContentState).owner) | |
} | |
} |
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 RepoInfoScreen( | |
githubViewModel: GithubViewModel | |
) { | |
val uiState by githubViewModel.rememberState() | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding(16.dp) |
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
@HiltViewModel | |
class GithubViewModel @Inject constructor( | |
githubStateMachine: GithubStateMachine | |
): AbsStateViewModel<GithubState, GithubAction>(githubStateMachine) |
NewerOlder