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
viewModelScope.launch { | |
manager.requestProgressFlow() | |
.collect { state -> ... } | |
} |
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
// BEFORE ISSUING INSTALL REQUEST | |
manager.registerListener(listener) | |
... | |
val listener = SplitInstallStateUpdatedListener { state -> | |
if (state.sessionId == sessionId) { | |
when (state.status()) { | |
// RESPOND TO PROGRESS EVENTS | |
} |
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
val extras = DynamicExtras(installMonitor = installMonitor) | |
navigate(destination, args, navOptions, extras) | |
installMonitor.status.observe(this, object : Observer { | |
override fun onChanged(state: SplitInstallSessionState?) { | |
… | |
} | |
} |
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
<navigation | |
… | |
app:progressFragment="@id/progress"> | |
<fragment | |
android:id="@+id/progress" | |
android:name="path.to.MyProgressFragment" /> | |
</navigation> |
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
abstract class AbstractProgressFragment(layoutId: Int) { | |
abstract fun onProgress(status: Int, bytesDownloaded: Long, bytesTotal: Long) | |
abstract fun onCancelled() | |
abstract fun onFailed(errorCode: Int) | |
} |
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
STUDIO_DIRS=`find $HOME -maxdepth 1 -name ".AndroidStudio*" -printf "%f "` | |
select dir in $STUDIO_DIRS "(create new)"; do | |
case $dir in | |
"(create new)") | |
echo "Enter the new directory suffix (after \".AndroidStudio\"):" | |
read dir | |
dir=".AndroidStudio${dir}" | |
;& | |
*) | |
dir=`echo $dir | cut -c 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
// one, few, many, other | |
// gram, gramy, gramów, grama | |
public static String getPlural(float quantity, String[] choices) { | |
if (quantity >= 1) { | |
switch (quantity == 1 ? 0 : (quantity % 10 >= 2 | |
&& quantity % 10 <= 4 | |
&& (quantity % 100 < 10 | |
|| quantity % 100 >= 20) ? 1 : 2)) { | |
case 0: |
NewerOlder