1 |
efrain |
1 |
package com.cesams.twogetskills.sync;
|
|
|
2 |
|
|
|
3 |
import android.accounts.Account;
|
|
|
4 |
import android.content.AbstractThreadedSyncAdapter;
|
|
|
5 |
import android.content.ContentProviderClient;
|
|
|
6 |
import android.content.Context;
|
|
|
7 |
import android.content.Intent;
|
|
|
8 |
import android.content.SyncResult;
|
|
|
9 |
import android.os.Build;
|
|
|
10 |
import android.os.Bundle;
|
|
|
11 |
import android.text.TextUtils;
|
|
|
12 |
import android.util.Log;
|
|
|
13 |
|
|
|
14 |
import com.cesams.twogetskills.Configuration;
|
|
|
15 |
import com.cesams.twogetskills.Constants;
|
|
|
16 |
import com.cesams.twogetskills.dao.SyncDao;
|
|
|
17 |
import com.cesams.twogetskills.library.Http;
|
|
|
18 |
import com.cesams.twogetskills.entity.Sync;
|
|
|
19 |
import com.cesams.twogetskills.preference.Preference;
|
|
|
20 |
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
|
|
|
21 |
|
|
|
22 |
import org.json.JSONException;
|
|
|
23 |
import org.json.JSONObject;
|
|
|
24 |
|
|
|
25 |
import java.io.IOException;
|
|
|
26 |
import java.util.List;
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
import okhttp3.Call;
|
|
|
30 |
import okhttp3.Callback;
|
|
|
31 |
import okhttp3.FormBody;
|
|
|
32 |
import okhttp3.OkHttpClient;
|
|
|
33 |
import okhttp3.Request;
|
|
|
34 |
import okhttp3.RequestBody;
|
|
|
35 |
import okhttp3.Response;
|
|
|
36 |
|
|
|
37 |
public class SyncAdapter extends AbstractThreadedSyncAdapter {
|
|
|
38 |
private Context mContext;
|
|
|
39 |
private ITwoGetSkills iTwoGetSkills;
|
|
|
40 |
private final static String TAG = "C2GS - SyncAdapter";
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
public SyncAdapter(Context context, boolean autoInitialize) {
|
|
|
44 |
super(context, autoInitialize);
|
|
|
45 |
|
|
|
46 |
Log.d(TAG, "Construct");
|
|
|
47 |
/*
|
|
|
48 |
* If your app uses a content resolver, get an instance of it
|
|
|
49 |
* from the incoming Context
|
|
|
50 |
*/
|
|
|
51 |
this.mContext = context;
|
|
|
52 |
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
@Override
|
|
|
56 |
public void onPerformSync(Account account,
|
|
|
57 |
Bundle extras,
|
|
|
58 |
String authority,
|
|
|
59 |
ContentProviderClient provider,
|
|
|
60 |
final SyncResult syncResult) {
|
|
|
61 |
|
|
|
62 |
Log.d(TAG, "onPerformSync");
|
|
|
63 |
|
|
|
64 |
Intent intent = new Intent(Constants.BROADCAST_TYPE_SYNC_TO_SERVER_OR_CHECK_CHANGES);
|
|
|
65 |
mContext.sendBroadcast(intent);
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
}
|