Welcome to mirror list, hosted at ThFree Co, Russian Federation.

OwnCloudSyncService.java « services « owncloudnewsreader « luhmer « de « java « main « src « News-Android-App - github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15693a0d2bc0e57250c6f418cead3481b8483943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package de.luhmer.owncloudnewsreader.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import de.luhmer.owncloudnewsreader.authentication.OwnCloudSyncAdapter;

public class OwnCloudSyncService extends Service {

    // https://developer.android.com/training/sync-adapters/creating-sync-adapter#java
    private static final String TAG = OwnCloudSyncService.class.getCanonicalName();

    private static final Object sSyncAdapterLock = new Object();
    private static OwnCloudSyncAdapter sSyncAdapter = null;

    @Override
    public void onCreate() {
        /*
        * Create the sync adapter as a singleton.
        * Set the sync adapter as syncable
        * Disallow parallel syncs
        */
        synchronized (sSyncAdapterLock) {
            if (sSyncAdapter == null) {
                sSyncAdapter = new OwnCloudSyncAdapter(getApplicationContext(), true);
            }
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        /*
        * Get the object that allows external processes
        * to call onPerformSync(). The object is created
        * in the base class code when the SyncAdapter
        * constructors call super()
        */
        return sSyncAdapter.getSyncAdapterBinder();
    }

    public static boolean isSyncRunning() {
        Log.d(TAG, "isSyncRunning() called");
        //return syncRunning;
        if(sSyncAdapter != null) {
            return sSyncAdapter.syncRunning;
        }
        return false;
    }
}