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
{ | |
"public_identifier": "levinyonatan", | |
"profile_pic_url": "https://miro.medium.com/v2/resize:fit:2400/1*x9Kj4IcodThKIKw249Rjtg.jpeg", | |
"background_cover_image_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/levinyonatan/cover?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230607%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230607T062927Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=9da9c62061281e41113414b8375d9e3ae1b9d9a981231d87194555b43d4e0c0e", | |
"first_name": "Yonatan (Yoni)", | |
"last_name": "Levin", | |
"full_name": "Yonatan (Yoni) Levin", | |
"follower_count": null, | |
"occupation": "R&D Team Leader at monday.com", | |
"headline": "Startups person. Community leader. Doer. \nLove to take things from 0 to 1 :)", |
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
{ | |
"public_identifier": "levinyonatan", | |
"profile_pic_url": "https://miro.medium.com/v2/resize:fit:2400/1*x9Kj4IcodThKIKw249Rjtg.jpeg", | |
"background_cover_image_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/levinyonatan/cover?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230605%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230605T074014Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=83f8feb228ee767a694c71180d9f4ad5abb62b8775ca5c8192326e32247dd6a6", | |
"first_name": "Yonatan (Yoni)", | |
"last_name": "Levin", | |
"full_name": "Yonatan (Yoni) Levin", | |
"follower_count": null, | |
"occupation": "R&D Team Leader at monday.com", | |
"headline": "Startups person. Community leader. Doer. \\nLove to take things from 0 to 1 :)", |
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
class CDataStream<T>( | |
private val taskRunner: ITaskRunner | |
) : IDataStream<T> { | |
private val channel = BroadcastChannel<T>(Channel.CONFLATED) | |
private var value: T? = null | |
override fun observe(observer: (T) -> Unit): IObservationManager { | |
val subscription = channel.openSubscription() | |
this.value?.let(observer) |
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
PeriodicWorkRequest locationWork = new PeriodicWorkRequest.Builder( | |
LocationWork.class, 15, TimeUnit.MINUTES).addTag(LocationWork.TAG).build(); | |
WorkManager.getInstance().enqueue(locationWork); |
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
public class LocationUploadWorker extends Worker { | |
//... | |
public WorkerResult doWork() { | |
//get Data out from input | |
double longitude = getInputData().getDouble(LOCATION_LONG, 0); | |
double latitude = getInputData().getDouble(LOCATION_LAT, 0); | |
long time = getInputData().getLong(LOCATION_TIME, 0); | |
String osVersion = "WorkerReport v" + Build.VERSION.SDK_INT; | |
//construct our report for server format |
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
//location obtained, need to send it to server | |
private void broadcastLocation(Location location) { | |
//release latch | |
reportFinished(); | |
//We need to sure that device have internet live | |
Constraints constraints = new Constraints.Builder().setRequiredNetworkType | |
(NetworkType.CONNECTED).build(); | |
//Parse our location to Data to use it as input for our worker | |
Data inputData = new Data.Builder() |
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
public class LocationWork extends Worker { | |
... | |
static void reportFinished() { | |
if (locationWait != null) { | |
Log.d(TAG, "doWork: locationWait down by one"); | |
locationWait.countDown(); | |
} | |
} |
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
public class LocationWork extends Worker { | |
... | |
public WorkerResult doWork() { | |
Log.d(TAG, "doWork: Started to work"); | |
handlerThread = new HandlerThread("MyHandlerThread"); | |
handlerThread.start(); | |
looper = handlerThread.getLooper(); | |
locationTracker = new LocationTracker(getApplicationContext(), looper); |
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
Constraints constraints = new Constraints.Builder().setRequiredNetworkType | |
(NetworkType.CONNECTED).build(); | |
PeriodicWorkRequest locationWork = new PeriodicWorkRequest.Builder(LocationWork | |
.class, 15, TimeUnit.MINUTES).addTag(LocationWork.TAG) | |
.setConstraints(constraints).build(); | |
WorkManager.getInstance().enqueue(locationWork); |
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
WorkManager.getInstance().getStatusById(locationWork.getId()).observe(this, | |
workStatus -> { | |
if(workStatus!=null && workStatus.getState().isFinished()){ | |
... | |
} | |
}); |
NewerOlder