| 19 |
efrain |
1 |
package com.cesams.twogetskills.inconcert.sync;
|
|
|
2 |
|
|
|
3 |
import android.content.Context;
|
|
|
4 |
import android.content.Intent;
|
|
|
5 |
import android.util.Log;
|
|
|
6 |
|
|
|
7 |
import androidx.annotation.NonNull;
|
|
|
8 |
import androidx.work.Worker;
|
|
|
9 |
import androidx.work.WorkerParameters;
|
|
|
10 |
|
|
|
11 |
import com.cesams.twogetskills.inconcert.Constants;
|
|
|
12 |
|
|
|
13 |
public class WorkSync extends Worker {
|
|
|
14 |
private final static String TAG = "C2GS - WorkSync";
|
|
|
15 |
private Context appContext;
|
|
|
16 |
|
|
|
17 |
public WorkSync(
|
|
|
18 |
@NonNull Context appContext,
|
|
|
19 |
@NonNull WorkerParameters workerParams) {
|
|
|
20 |
super(appContext, workerParams);
|
|
|
21 |
|
|
|
22 |
this.appContext = appContext;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
@NonNull
|
|
|
26 |
@Override
|
|
|
27 |
public Result doWork() {
|
|
|
28 |
|
|
|
29 |
Log.d(TAG, "doWork");
|
|
|
30 |
|
|
|
31 |
Intent intent = new Intent(Constants.BROADCAST_TYPE_SYNC_TO_SERVER_OR_CHECK_CHANGES);
|
|
|
32 |
appContext.sendBroadcast(intent);
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
return Result.success();
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
@Override
|
|
|
39 |
public void onStopped() {
|
|
|
40 |
super.onStopped();
|
|
|
41 |
Log.i(TAG, "OnStopped called for this worker");
|
|
|
42 |
}
|
|
|
43 |
}
|