Using keystore.properties files (create it in project root, gitignored)
Contents of keystore.properties
storePassword=mypass
keyPassword=mypass
keyAlias=key0
Using keystore.properties files (create it in project root, gitignored)
Contents of keystore.properties
storePassword=mypass
keyPassword=mypass
keyAlias=key0
| // I had partial success, the file plays but in media players the duration will be shown of original audio and the position jumping to trimmed section | |
| // with dependency on https://github.com/leonfancy/oggus | |
| // See issue: https://github.com/leonfancy/oggus/issues/2 | |
| import org.chenliang.oggus.ogg.OggPage; | |
| import org.chenliang.oggus.ogg.OggStream; |
| suspendCoroutineUninterceptedOrReturn<Unit> { cont -> | |
| Compressor.compress(image)( | |
| onSuccess = { | |
| DispatcherContinuation(cont.context, cont).resumeWith(Result.success(Unit)) | |
| } | |
| ) | |
| COROUTINE_SUSPENDED | |
| } |
| fun copyFiles(files: List<File>, destination: File){ | |
| for(file in files){ | |
| launch(Dispatcher.Background){ | |
| ... | |
| } | |
| } | |
| } |
| class FileCopyFragment : Fragment() { | |
| fun copyFiles(files: List<File>, destination: File) { | |
| launch(Dispatcher.Background) { | |
| for (file in files) { | |
| val needsOverride = destination.listFiles()?.any { it.name == file.name } ?: false | |
| if (needsOverride && !confirmFileOverride(file.name)) { | |
| continue | |
| } | |
| file.copyTo(destination) | |
| } |
| fun <T> (suspend () -> T).createCoroutine( | |
| completion: Continuation<T> | |
| ): Continuation<Unit> { | |
| val coroutine = createCoroutineUnintercepted(completion) | |
| return DispatcherContinuation(completion.context,coroutine) | |
| } |
| import android.os.Handler | |
| import android.os.Looper | |
| import kotlin.concurrent.thread | |
| import kotlin.coroutines.Continuation | |
| import kotlin.coroutines.CoroutineContext | |
| import kotlin.coroutines.intrinsics.createCoroutineUnintercepted | |
| import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn | |
| import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED | |
| sealed class Dispatcher : CoroutineContext.Element { |
| suspend fun <T> suspendCoroutine(block: (Continuation<T>) -> Unit): T { | |
| return suspendCoroutineUninterceptedOrReturn { cont -> | |
| // block(cont) | |
| val dispatchedContinuation = DispatcherContinuation(cont.context, cont) | |
| block(dispatchedContinuation) | |
| COROUTINE_SUSPENDED | |
| } | |
| } |
| // Resumes a coroutine on specified dispatcher | |
| class DispatcherContinuation<T>( | |
| override val context: CoroutineContext, | |
| val continuation: Continuation<T> | |
| ) : Continuation<T> { | |
| override fun resumeWith(result: Result<T>) { | |
| when (context as Dispatcher) { | |
| Dispatcher.Main -> Handler(Looper.getMainLooper()).post { | |
| continuation.resumeWith(result) | |
| } |
| fun launch(dispatcher: Dispatcher, block: suspend () -> Unit) { | |
| val callback = object : Continuation<Unit> { | |
| override val context: CoroutineContext = dispatcher | |
| override fun resumeWith(result: Result<Unit>) {} | |
| } | |
| val coroutine = block.createCoroutineUnintercepted(callback) | |
| // Duplicate code #1 | |
| when (dispatcher) { | |
| Dispatcher.Main -> Handler(Looper.getMainLooper()).post { | |
| coroutine.resumeWith(Result.success(Unit)) |