Skip to content

Instantly share code, notes, and snippets.

View akueisara's full-sized avatar
🎹

Kuei-Jung Hu akueisara

🎹
View GitHub Profile
val request = OneTimeWorkRequestBuilder<YourWorker>()
// OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST, which causes the job to run as an ordinary work request
// OutOfQuotaPolicy.DROP_WORK_REQUEST, which causes the request to cancel if there is not sufficient quota.
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.build()
WorkManager.getInstance(context).enqueue(request)
val constraints = Constraints.Builder()
.setRequiresCharging(true)
.build()
val work = PeriodicWorkRequestBuilder<MyWorker>(
// repeatInterval (the period cycle), its minimum is 15 minutes
1, TimeUnit.HOURS,
// flexInterval, its minimum is 5 minutes
15, TimeUnit.MINUTES)
.setConstraints(constraints)
@akueisara
akueisara / CancelWork.kt
Last active June 26, 2022 16:29 — forked from ceruleanotter/SimpleWorkStatusObservation.kt
WorkManager Basics: WorkStatus Observation
WorkManager.getInstance().cancelWorkById(uploadWorkRequest.id)
WorkManager.getInstance().cancelAllWorkByTag("sometag")
@akueisara
akueisara / SimpleChain.kt
Last active June 25, 2022 14:17 — forked from ceruleanotter/SimpleChain.kt
WorkManager Basics: Simple Chain Example
WorkManager.getInstance()
// These three work requests run in parallel
.beginWith(Arrays.asList(
filterImageOneWorkRequest,
filterImageTwoWorkRequest,
filterImageThreeWorkRequest))
// The output from the filter WorkRequests
// will be passed as the input of compress WorkRequest
.then(compressWorkRequest)
.then(uploadWorkRequest)
@akueisara
akueisara / WorkRequestCompleteExample.kt
Last active June 26, 2022 16:15 — forked from ceruleanotter/WorkRequestCompleteExample.kt
WorkManager Basics: Complete WorkRequest Example
// 1. Create the Constraints
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
// Other supported Constraints
val exampleConstraints = Constraints.Builder()
.setRequiresBatteryNotLow(true)
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiresCharging(true)
@akueisara
akueisara / UploadWorker.kt
Last active June 25, 2022 06:35 — forked from ceruleanotter/UploadWorker.kt
WorkManager Basics - UploadWorker.kt Example
class UploadWorker(appContext: Context, workerParams: WorkerParameters)
: Worker(appContext, workerParams) {
override fun doWork(): Result {
try {
// Get the input, where this inputData is set when building the WorkRequest
val imageUriInput = inputData.getString(Constants.KEY_IMAGE_URI)
// Do the work
val response = upload(imageUriInput)
curl https://raw.githubusercontent.com/omnirom/android_device_brcm_rpi4/android-12.0/repo/local_manifest.xml -o local_manifest.xml
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@akueisara
akueisara / Build YourFrameworkName.xcframework.txt
Last active November 9, 2021 12:47
Build YourFrameworkName.xcframework
xcodebuild archive ONLY_ACTIVE_ARCH=NO \
-scheme YourFrameworkName \
-destination "generic/platform=iOS Simulator" \
-archivePath YourFrameworkName-iphonesimulator.xcarchive \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme YourFrameworkName \
@akueisara
akueisara / gist:e690fd7c10cc60048b6687129d6ca481
Created July 31, 2021 04:41
Build a Universal iOS Framework
lipo -create -output Kuei.framework KueiDevice.framework/KueiDevice KueiSim.framework/KueiSim