-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
245 additions
and
140 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
61 changes: 61 additions & 0 deletions
61
...id/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/DynamicInstaller.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
import com.google.android.play.core.ktx.status | ||
import com.google.android.play.core.splitinstall.SplitInstallManager | ||
import com.google.android.play.core.splitinstall.SplitInstallRequest | ||
import com.google.android.play.core.splitinstall.SplitInstallSessionState | ||
import com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener | ||
import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus | ||
|
||
class DynamicInstaller( | ||
private val request: SplitInstallRequest, | ||
private val manager: SplitInstallManager, | ||
) : Installer { | ||
|
||
private var mySessionId = 0 | ||
|
||
override fun install(callback: SoundInstalledCallback) { | ||
val installListener = InstallListener(callback) | ||
manager.registerListener(installListener) | ||
manager.startInstall(request) | ||
.addOnCompleteListener { } | ||
.addOnSuccessListener { mySessionId = it } | ||
.addOnFailureListener { callback.onError() } | ||
} | ||
} | ||
|
||
class InstallListener( | ||
private val callback: SoundInstalledCallback, | ||
) : SplitInstallStateUpdatedListener { | ||
|
||
override fun onStateUpdate(state: SplitInstallSessionState) { | ||
when (state.status()) { | ||
SplitInstallSessionStatus.DOWNLOADING -> { | ||
val totalBytes = state.totalBytesToDownload() | ||
val bytes = state.bytesDownloaded() | ||
callback.onProgress(bytes, totalBytes) | ||
} | ||
SplitInstallSessionStatus.INSTALLED -> { | ||
|
||
// After a module is installed, you can start accessing its content or | ||
// fire an intent to start an activity in the installed module. | ||
// For other use cases, see access code and resources from installed modules. | ||
|
||
// If the request is an on demand module for an Android Instant App | ||
// running on Android 8.0 (API level 26) or higher, you need to | ||
// update the app context using the SplitInstallHelper API. | ||
callback.onComplete() | ||
} | ||
SplitInstallSessionStatus.CANCELED, | ||
SplitInstallSessionStatus.CANCELING, | ||
SplitInstallSessionStatus.DOWNLOADED, | ||
SplitInstallSessionStatus.FAILED, | ||
SplitInstallSessionStatus.INSTALLING, | ||
SplitInstallSessionStatus.PENDING, | ||
SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION, | ||
SplitInstallSessionStatus.UNKNOWN -> { | ||
callback.onDebug(state.status()) | ||
} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/Installer.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
interface Installer { | ||
fun install(callback: SoundInstalledCallback) | ||
} |
5 changes: 5 additions & 0 deletions
5
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/NoInstaller.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
class NoInstaller : Installer { | ||
override fun install(callback: SoundInstalledCallback) {} | ||
} |
40 changes: 5 additions & 35 deletions
40
...d/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/NoMusicRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,14 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
import com.google.android.play.core.internal.r | ||
import com.google.android.play.core.splitinstall.SplitInstallManager | ||
import com.google.android.play.core.splitinstall.SplitInstallRequest | ||
import nl.entreco.domain.mastercaller.MusicRepository | ||
import nl.entreco.liblog.Logger | ||
|
||
class NoMusicRepository: MusicRepository { | ||
|
||
/************************************************************************* | ||
* | ||
* ONWARD CONFIDENTIAL | ||
* __________________ | ||
* | ||
* [2021] ONWARD | ||
* All Rights Reserved. | ||
* | ||
*/ | ||
class NoMusicRepository( | ||
private val logger: Logger, | ||
private val request: SplitInstallRequest, | ||
private val manager: SplitInstallManager | ||
) : MusicRepository { | ||
override fun play() {} | ||
|
||
override fun play() { | ||
logger.i("Music play") | ||
manager.startInstall(request) | ||
.addOnCompleteListener{ logger.i("Music - installed") } | ||
.addOnSuccessListener { logger.i("Music - loading") } | ||
.addOnFailureListener { logger.i("Music - error: ${it.localizedMessage}") } | ||
} | ||
override fun pause() {} | ||
|
||
override fun pause() { | ||
logger.i("Music pause") | ||
} | ||
override fun resume() {} | ||
|
||
override fun resume() { | ||
logger.i("Music resume") | ||
} | ||
|
||
override fun stop() { | ||
logger.i("Music stop") | ||
} | ||
override fun stop() {} | ||
} |
30 changes: 3 additions & 27 deletions
30
...d/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/NoSoundRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,11 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
import com.google.android.play.core.splitinstall.SplitInstallManager | ||
import com.google.android.play.core.splitinstall.SplitInstallRequest | ||
import nl.entreco.domain.mastercaller.Sound | ||
import nl.entreco.domain.mastercaller.SoundRepository | ||
import nl.entreco.liblog.Logger | ||
|
||
/************************************************************************* | ||
* | ||
* ONWARD CONFIDENTIAL | ||
* __________________ | ||
* | ||
* [2021] ONWARD | ||
* All Rights Reserved. | ||
* | ||
*/ | ||
class NoSoundRepository( | ||
private val logger: Logger, | ||
private val request: SplitInstallRequest, | ||
private val manager: SplitInstallManager | ||
) : SoundRepository { | ||
class NoSoundRepository : SoundRepository { | ||
|
||
override fun play(sound: Sound) { | ||
logger.i("Sound play: $sound") | ||
manager.startInstall(request) | ||
.addOnCompleteListener{ logger.i("Sound - installed") } | ||
.addOnSuccessListener { logger.i("Sound - loading") } | ||
.addOnFailureListener { logger.i("Sound - error: ${it.localizedMessage}") } | ||
} | ||
override fun play(sound: Sound) {} | ||
|
||
override fun release() { | ||
logger.i("Sound release") | ||
} | ||
override fun release() {} | ||
} |
8 changes: 8 additions & 0 deletions
8
...tsScorecard/app/src/main/java/nl/entreco/dartsscorecard/dynamic/SoundInstalledCallback.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package nl.entreco.dartsscorecard.dynamic | ||
|
||
interface SoundInstalledCallback { | ||
fun onComplete() | ||
fun onProgress(bytes: Long, totalBytes: Long) | ||
fun onError() | ||
fun onDebug(status: 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
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
Oops, something went wrong.