Java Code Examples for com.nextgis.maplib.util.Constants#DEBUG_MODE

The following examples show how to use com.nextgis.maplib.util.Constants#DEBUG_MODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NGWVectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected HttpResponse sendFeatureAttachOnServer(JSONObject result, long featureId, AttachItem attach) throws JSONException, IOException {
    // add attachment to row
    JSONObject postJsonData = new JSONObject();
    JSONArray uploadMetaArray = result.getJSONArray("upload_meta");
    postJsonData.put("file_upload", uploadMetaArray.get(0));
    postJsonData.put("description", attach.getDescription());
    String postload = postJsonData.toString();
    if (Constants.DEBUG_MODE) {
        Log.d(Constants.TAG, "postload: " + postload);
    }

    // get account data
    AccountUtil.AccountData accountData = AccountUtil.getAccountData(mContext, mAccountName);

    // upload file
    String url = NGWUtil.getFeatureAttachmentUrl(accountData.url, mRemoteId, featureId);

    // update record in NGW
    return NetworkUtil.post(url, postload, accountData.login, accountData.password, false);
}
 
Example 2
Source File: TileDownloadService.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void addDownloadTask(Intent intent) {
    if (Constants.DEBUG_MODE) {
        Log.d(Constants.TAG, "Add task to download queue");
    }
    String layerPathName = intent.getStringExtra(KEY_PATH);
    double dfMinX = intent.getDoubleExtra(KEY_MINX, 0);
    double dfMinY = intent.getDoubleExtra(KEY_MINY, 0);
    double dfMaxX = intent.getDoubleExtra(KEY_MAXX, GeoConstants.MERCATOR_MAX);
    double dfMaxY = intent.getDoubleExtra(KEY_MAXY, GeoConstants.MERCATOR_MAX);
    GeoEnvelope env = new GeoEnvelope(dfMinX, dfMaxX, dfMinY, dfMaxY);

    if (intent.hasExtra(KEY_ZOOM_FROM) && intent.hasExtra(KEY_ZOOM_TO)) {
        int zoomFrom = intent.getIntExtra(KEY_ZOOM_FROM, 0);
        int zoomTo = intent.getIntExtra(KEY_ZOOM_TO, 18);
        addTask(layerPathName, env, zoomFrom, zoomTo);
    } else if (intent.hasExtra(KEY_ZOOM_LIST)) {
        List<Integer> zoomList = intent.getIntegerArrayListExtra(KEY_ZOOM_LIST);
        addTask(layerPathName, env, zoomList);
    }
}
 
Example 3
Source File: Layer.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void fromJSON(JSONObject jsonObject)
        throws JSONException
{
    super.fromJSON(jsonObject);
    if (jsonObject.has(JSON_MAXLEVEL_KEY)) {
        mMaxZoom = (float) jsonObject.getDouble(JSON_MAXLEVEL_KEY);
    } else {
        mMaxZoom = GeoConstants.DEFAULT_MAX_ZOOM;
    }
    if (jsonObject.has(JSON_MINLEVEL_KEY)) {
        mMinZoom = (float) jsonObject.getDouble(JSON_MINLEVEL_KEY);
    } else {
        mMinZoom = GeoConstants.DEFAULT_MIN_ZOOM;
    }

    mIsVisible = jsonObject.getBoolean(JSON_VISIBILITY_KEY);

    if(Constants.DEBUG_MODE){
        Log.d(Constants.TAG, "Layer " + getName() + " is visible " + mIsVisible);
        Log.d(Constants.TAG, "Layer " + getName() + " zoom limits from " + mMinZoom + " to " + mMaxZoom);
    }
}
 
Example 4
Source File: GpsEventSource.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void requestUpdates() {
    if (0 != (mListenProviders & GPS_PROVIDER) &&
            mLocationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) {

        mLocationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, mUpdateMinTime, mUpdateMinDistance,
                mGpsLocationListener);

        if(Constants.DEBUG_MODE)
            Log.d(Constants.TAG, "GpsEventSource request location updates for " + LocationManager.GPS_PROVIDER);
    }

    if (0 != (mListenProviders & NETWORK_PROVIDER) &&
            mLocationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) {

        mLocationManager.requestLocationUpdates(
                LocationManager.NETWORK_PROVIDER, mUpdateMinTime, mUpdateMinDistance,
                mGpsLocationListener);

        if(Constants.DEBUG_MODE)
            Log.d(Constants.TAG, "GpsEventSource request location updates for " + LocationManager.NETWORK_PROVIDER);
    }
}
 
Example 5
Source File: TileDownloadService.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void addTask(
        String layerPathName,
        GeoEnvelope env,
        List<Integer> zoomList)
{
    DownloadTask task = new DownloadTask(layerPathName, env, zoomList);
    mQueue.add(task);

    if (mDownloadThread == null) {
        if (Constants.DEBUG_MODE) {
            Log.d(
                    Constants.TAG,
                    "TileDownloadService.addTask(), create and run download thread");
        }
        mDownloadThread = createDownloadThread();
        mDownloadThread.start();
    }
}
 
Example 6
Source File: MapView.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onLayerDrawFinished(int id, float percent)
{
    if(Constants.DEBUG_MODE) {
        Log.d(TAG, "onLayerDrawFinished: " + id + " percent " + percent + " | draw state: " + mDrawingState);
    }

    if (mDrawingState > DRAW_STATE_drawing_noclearbk) {
        return;
    }

    if (System.currentTimeMillis() - mStartDrawTime > DISPLAY_REDRAW_TIMEOUT) {
        mStartDrawTime = System.currentTimeMillis();
        mMap.buffer(0, 0, 1);
        postInvalidate();

    } else if (id == DRAW_FINISH_ID && percent >= 1.0) {
        //Log.d(TAG, "LayerDrawFinished: id - " + id + ", percent - " + percent);

        mMap.buffer(0, 0, 1);
        postInvalidate();
    }
}
 
Example 7
Source File: VectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
public long createFeature(Feature feature)
        throws SQLiteException
{
    if (null == feature.getGeometry() || !checkGeometryType(feature)) {
        return NOT_FOUND;
    }

    if (!mCacheLoaded) {
        reloadCache();
    }

    // check if such id already used
    // maybe was added previous session
    if (mCache.getItem(feature.getId()) != null) {
        return NOT_FOUND;
    }

    MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance();
    SQLiteDatabase db = map.getDatabase(false);

    final ContentValues values = getFeatureContentValues(feature);

    if (Constants.DEBUG_MODE) {
        Log.d(TAG, "Inserting " + values);
    }
    long rowId = db.insert(mPath.getName(), "", values);
    if (rowId != Constants.NOT_FOUND) {
        //update bbox
        cacheGeometryEnvelope(rowId, feature.getGeometry());
        save();
    }

    return rowId;
}
 
Example 8
Source File: VectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void notifyUpdate(
        long rowId,
        long oldRowId,
        boolean attributesOnly)
{
    if (Constants.DEBUG_MODE) {
        Log.d(Constants.TAG, "notifyUpdate id: " + rowId + ", old_id: " + oldRowId);
    }

    boolean needSave = false;
    if (oldRowId != Constants.NOT_FOUND) {
        mCache.changeId(oldRowId, rowId);
        if (DEBUG_MODE)
            Log.d(Constants.TAG, "mCache: changing id from " + oldRowId + " to " + rowId);
        needSave = true;
    }

    GeoGeometry geom = getGeometryForId(rowId);
    if (null != geom && !attributesOnly) {
        mCache.removeItem(rowId);
        cacheGeometryEnvelope(rowId, geom);
        if (DEBUG_MODE)
            Log.d(Constants.TAG, "mCache: removing item " + oldRowId + " and caching env");
        needSave = true;
    }

    if (needSave) {
        save();
    }

    notifyLayerChanged();
}
 
Example 9
Source File: LocalTMSLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Bitmap getBitmap(TileItem tile)
{
    Bitmap ret = getBitmapFromCache(tile.getHash());
    if (null != ret) {
        if(Constants.DEBUG_MODE) {
            Log.d(Constants.TAG, "Raster layer " + getName() + " getBitmap from cache for: " + tile.toString());
        }
        return ret;
    }

    TileCacheLevelDescItem item = mLimits.get(tile.getZoomLevel());
    boolean isInside = item != null && item.isInside(tile.getX(), tile.getY());
    if (isInside) {
        File tilePath = new File(mPath, tile.toString() + TILE_EXT);
        boolean isExist = tilePath.exists();
        if (isExist) {
            ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath());
            putBitmapToCache(tile.getHash(), ret);
            if(Constants.DEBUG_MODE) {
                Log.d(Constants.TAG, "Raster layer " + getName() + " getBitmap for: " + tile.toString() + ", path " + tilePath.getAbsolutePath() + " is valid - " + (ret != null));
            }
            return ret;
        }
    }

    if(Constants.DEBUG_MODE && isInside) {
        Log.d(Constants.TAG, "Raster layer " + getName() + " getBitmap failed for: " + tile.toString());
    }
    return null;
}
 
Example 10
Source File: NGWVectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void log(Exception e, String tag) {
    e.printStackTrace();
    if (Constants.DEBUG_MODE) {
        String error = e.getLocalizedMessage() == null ? tag + ": Exception" : e.getLocalizedMessage();
        Log.d(Constants.TAG, error);
    }
}
 
Example 11
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
void testAttachUpdate()
{
    IGISApplication application = (IGISApplication) getApplication();
    /*MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for(int i = 0; i < map.getLayerCount(); i++){
        ILayer layer = map.getLayer(i);
        if(layer instanceof NGWVectorLayer)
        {
            ngwVectorLayer = (NGWVectorLayer)layer;
        }
    }
    if(null != ngwVectorLayer) {
        Uri updateUri = Uri.parse("content://" + SettingsConstants.AUTHORITY + "/" +
                                  ngwVectorLayer.getPath().getName() + "/36/attach/1000");
    */
    Uri updateUri = Uri.parse(
            "content://" + AppSettingsConstants.AUTHORITY +
            "/layer_20150210140455993/36/attach/2");

    ContentValues values = new ContentValues();
    values.put(VectorLayer.ATTACH_DISPLAY_NAME, "no_image.jpg");
    values.put(VectorLayer.ATTACH_DESCRIPTION, "simple update description");
    //    values.put(VectorLayer.ATTACH_ID, 999);
    int result = getContentResolver().update(updateUri, values, null, null);
    if(Constants.DEBUG_MODE){
        if (result == 0) {
            Log.d(TAG, "update failed");
        } else {
            Log.d(TAG, "" + result);
        }
    }
    //}
}
 
Example 12
Source File: GISApplication.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Account getAccount(String accountName)
{
    if(!PermissionUtil.hasPermission(this, Manifest.permission.GET_ACCOUNTS)){
        return null;
    }

    if (!isAccountManagerValid()) {
        return null;
    }
    try {
        for (Account account : mAccountManager.getAccountsByType(getAccountsType())) {
            if (account == null) {
                continue;
            }
            if(Constants.DEBUG_MODE)
                Log.d(Constants.TAG, "getAccount check account: " + account.toString());
            if (account.name.equals(accountName)) {
                return account;
            }
        }
    }
    catch (SecurityException e){
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Source File: TileDownloadService.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Thread createDownloadThread() {
    mIsDownloadInterrupted = false;
    return new Thread(new Runnable()
    {
        @Override
        public void run()
        {
            if (Constants.DEBUG_MODE) {
                Log.d(Constants.TAG, "TileDownloadService.mDownloadThread, started");
            }

            while (!mQueue.isEmpty()) {
                if (mIsDownloadInterrupted) {
                    break;
                }
                if (Constants.DEBUG_MODE) {
                    Log.d(Constants.TAG, "Tile download queue size " + mQueue.size());
                }
                DownloadTask task = mQueue.poll();
                download(task);
            }

            cancelNotification();
            stopSelf();

            if (Constants.DEBUG_MODE) {
                Log.d(Constants.TAG, "TileDownloadService.stopSelf() is performed");
                Log.d(Constants.TAG, "TileDownloadService.mDownloadThread, stopped");
            }
        }
    });
}
 
Example 14
Source File: TileDownloadService.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
    clearResources();
    if (Constants.DEBUG_MODE) {
        Log.d(Constants.TAG, "TileDownloadService.onDestroy(), service is stopped");
    }
    super.onDestroy();
}
 
Example 15
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
void testAttachDelete()
{
    IGISApplication application = (IGISApplication) getApplication();
    /*MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for(int i = 0; i < map.getLayerCount(); i++){
        ILayer layer = map.getLayer(i);
        if(layer instanceof NGWVectorLayer)
        {
            ngwVectorLayer = (NGWVectorLayer)layer;
        }
    }
    if(null != ngwVectorLayer) {
        Uri deleteUri = Uri.parse("content://" + SettingsConstants.AUTHORITY + "/" +
                            ngwVectorLayer.getPath().getName() + "/36/attach/1000");
    */
    Uri deleteUri = Uri.parse(
            "content://" + AppSettingsConstants.AUTHORITY +
                    "/layer_20150210140455993/36/attach/1");
    int result = getContentResolver().delete(deleteUri, null, null);
    if(Constants.DEBUG_MODE){
        if (result == 0) {
            Log.d(TAG, "delete failed");
        } else {
            Log.d(TAG, "" + result);
        }
    }
    //}
}
 
Example 16
Source File: VectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void notifyInsert(long rowId)
{

    if (Constants.DEBUG_MODE) {
        Log.d(Constants.TAG, "notifyInsert id: " + rowId);
    }

    GeoGeometry geom = getGeometryForId(rowId);
    if (null != geom) {
        cacheGeometryEnvelope(rowId, geom);
        save();
        notifyLayerChanged();
    }
}
 
Example 17
Source File: MapEventSource.java    From android_maplib with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
     * Create handler for messages
     */
    protected void createHandler()
    {
        mHandler = new Handler()
        {
            public void handleMessage(Message msg)
            {
                super.handleMessage(msg);

                if (mFreeze) {
                    return;
                }

                Bundle resultData = msg.getData();

                Long lastTime = mLastMessages.get(resultData.getInt(BUNDLE_TYPE_KEY));
                if(lastTime != null && System.currentTimeMillis() - lastTime < SKIP_TIMEOUT){
                    boolean filter = !(EVENT_onExtentChanged == resultData.getInt(BUNDLE_TYPE_KEY) ||
                            EVENT_onLayerDrawFinished == resultData.getInt(BUNDLE_TYPE_KEY));
                    if(filter) {
                        if(Constants.DEBUG_MODE) {
                            Log.d(TAG, "handleMessage: skip event: " + resultData.getInt(BUNDLE_TYPE_KEY));
                        }
                        return;
                    }
//                    else{
//                        if(resultData.getFloat(BUNDLE_DONE_KEY) < 1){
//
//                            if(Constants.DEBUG_MODE) {
//                                Log.d(TAG, "handleMessage: skip event: " + resultData.getInt(BUNDLE_TYPE_KEY));
//                            }
//
//                            return;
//                        }
//                    }
                }
                mLastMessages.put(resultData.getInt(BUNDLE_TYPE_KEY), System.currentTimeMillis());

                for (MapEventListener listener : mListeners) {
                    switch (resultData.getInt(BUNDLE_TYPE_KEY)) {
                        case EVENT_onLayerAdded:
                            listener.onLayerAdded(resultData.getInt(BUNDLE_ID_KEY));
                            break;
                        case EVENT_onLayerDeleted:
                            listener.onLayerDeleted(resultData.getInt(BUNDLE_ID_KEY));
                            break;
                        case EVENT_onLayerChanged:
                            listener.onLayerChanged(resultData.getInt(BUNDLE_ID_KEY));
                            break;
                        case EVENT_onExtentChanged:
                            listener.onExtentChanged(
                                    resultData.getFloat(BUNDLE_ZOOM_KEY), new GeoPoint(
                                            resultData.getDouble(BUNDLE_X_KEY),
                                            resultData.getDouble(BUNDLE_Y_KEY)));
                            break;
                        case EVENT_onLayerDrawFinished:
                            listener.onLayerDrawFinished(
                                    resultData.getInt(BUNDLE_ID_KEY),
                                    resultData.getFloat(BUNDLE_DONE_KEY));
                            break;
                        case EVENT_onLayersReordered:
                            listener.onLayersReordered();
                            break;
                        case EVENT_onLayerDrawStarted:
                            listener.onLayerDrawStarted();
                            break;
                    }
                }
            }
        };
    }
 
Example 18
Source File: MapFragment.java    From android_gisapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();

    boolean showControls = mPreferences.getBoolean(KEY_PREF_SHOW_ZOOM_CONTROLS, false);
    showMapButtons(showControls, mMapRelativeLayout);

    if(Constants.DEBUG_MODE)
        Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF"));

    showControls = mPreferences.getBoolean(KEY_PREF_SHOW_SCALE_RULER, true);
    if (showControls)
        mScaleRulerLayout.setVisibility(View.VISIBLE);
    else
        mScaleRulerLayout.setVisibility(View.GONE);

    showControls = mPreferences.getBoolean(KEY_PREF_SHOW_ZOOM, false);
    if (showControls)
        mZoomLevel.setVisibility(View.VISIBLE);
    else
        mZoomLevel.setVisibility(View.GONE);

    showControls = mPreferences.getBoolean(KEY_PREF_SHOW_MEASURING, false);
    if (showControls)
        mRuler.setVisibility(View.VISIBLE);
    else
        mRuler.setVisibility(View.GONE);

    if (null != mMap) {
        mMap.getMap().setBackground(mApp.getMapBackground());
        mMap.addListener(this);
    }

    String coordinatesFormat = mPreferences.getString(SettingsConstantsUI.KEY_PREF_COORD_FORMAT, Location.FORMAT_DEGREES + "");
    if (FileUtil.isIntegerParseInt(coordinatesFormat))
        mCoordinatesFormat = Integer.parseInt(coordinatesFormat);
    else
        mCoordinatesFormat = Location.FORMAT_DEGREES;
    mCoordinatesFraction = mPreferences.getInt(SettingsConstantsUI.KEY_PREF_COORD_FRACTION, DEFAULT_COORDINATES_FRACTION_DIGITS);

    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay.updateMode(mPreferences.getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3"));
        mCurrentLocationOverlay.startShowingCurrentLocation();
    }
    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
        if (mGPSDialog == null || !mGPSDialog.isShowing())
            mGPSDialog = NotificationHelper.showLocationInfo(getActivity());
    }

    if (null != mEditLayerOverlay) {
        mEditLayerOverlay.addListener(this);
        mEditLayerOverlay.onResume();
    }

    try {
        String statusPanelModeStr = mPreferences.getString(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, "1");
        if (FileUtil.isIntegerParseInt(statusPanelModeStr))
            mStatusPanelMode = Integer.parseInt(statusPanelModeStr);
        else
            mStatusPanelMode = 0;
    } catch (ClassCastException e){
        mStatusPanelMode = 0;
        if(Constants.DEBUG_MODE)
            Log.d(Constants.TAG, "Previous version of KEY_PREF_SHOW_STATUS_PANEL of bool type. Let set it to 0");
    }

    if (null != mStatusPanel) {
        if (mStatusPanelMode != 0) {
            mStatusPanel.setVisibility(View.VISIBLE);
            fillStatusPanel(null);

            if (mMode != MODE_NORMAL && mStatusPanelMode != 3)
                mStatusPanel.setVisibility(View.INVISIBLE);
        } else {
            mStatusPanel.removeAllViews();
        }

        setMarginsToPanel();
    }

    boolean showCompass = mPreferences.getBoolean(KEY_PREF_SHOW_COMPASS, true);
    checkCompass(showCompass);

    mCurrentCenter = null;
}
 
Example 19
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 4 votes vote down vote up
void testAttachInsert()
{
    IGISApplication application = (IGISApplication) getApplication();
    /*MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for(int i = 0; i < map.getLayerCount(); i++){
        ILayer layer = map.getLayer(i);
        if(layer instanceof NGWVectorLayer)
        {
            ngwVectorLayer = (NGWVectorLayer)layer;
        }
    }
    if(null != ngwVectorLayer) {
        Uri uri = Uri.parse("content://" + SettingsConstants.AUTHORITY + "/" + ngwVectorLayer.getPath().getName() + "/36/attach");
    */
    Uri uri = Uri.parse(
            "content://" + AppSettingsConstants.AUTHORITY + "/layer_20150210140455993/36/attach");
    ContentValues values = new ContentValues();
    values.put(VectorLayer.ATTACH_DISPLAY_NAME, "test_image.jpg");
    values.put(VectorLayer.ATTACH_MIME_TYPE, "image/jpeg");
    values.put(VectorLayer.ATTACH_DESCRIPTION, "test image description");

    Uri result = getContentResolver().insert(uri, values);
    if (result == null) {
        Log.d(TAG, "insert failed");
    } else {
        try {
            OutputStream outStream = getContentResolver().openOutputStream(result);
            Bitmap sourceBitmap = BitmapFactory.decodeResource(
                    getResources(), com.nextgis.maplibui.R.drawable.bk_tile);
            sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 75, outStream);
            outStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if(Constants.DEBUG_MODE)
            Log.d(TAG, result.toString());
    }
    //}
}
 
Example 20
Source File: TrackerService.java    From android_maplibui with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String targetActivity = "";

    if (intent != null) {
        targetActivity = intent.getStringExtra(ConstantsUI.TARGET_CLASS);
        String action = intent.getAction();

        if (action != null && !TextUtils.isEmpty(action)) {
            switch (action) {
                case ACTION_SYNC:
                    if (mIsRunning || mLocationSenderThread != null)
                        return START_STICKY;

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        int res = R.string.sync_started;
                        String title = getString(res);
                        NotificationCompat.Builder builder = createBuilder(this, res);
                        builder.setSmallIcon(mSmallIcon)
                                .setLargeIcon(mLargeIcon)
                                .setTicker(title)
                                .setWhen(System.currentTimeMillis())
                                .setAutoCancel(false)
                                .setContentTitle(title)
                                .setContentText(title)
                                .setOngoing(true);

                        startForeground(TRACK_NOTIFICATION_ID, builder.build());
                    }

                    mLocationSenderThread = createLocationSenderThread(500L);
                    mLocationSenderThread.start();
                    return START_NOT_STICKY;
                case ACTION_STOP:
                    removeNotification();
                    stopSelf();
                    return START_NOT_STICKY;
                case ACTION_SPLIT:
                    stopTrack();
                    startTrack();
                    addNotification();
                    return START_STICKY;
            }
        }
    }

    if (!mIsRunning) {
        if (!PermissionUtil.hasLocationPermissions(this)) {
            stopForeground(true);
            stopSelf();
            return START_NOT_STICKY;
        }

        mLocationManager.addGpsStatusListener(this);

        String time = SettingsConstants.KEY_PREF_TRACKS_MIN_TIME;
        String distance = SettingsConstants.KEY_PREF_TRACKS_MIN_DISTANCE;
        String minTimeStr = mSharedPreferences.getString(time, "2");
        String minDistanceStr = mSharedPreferences.getString(distance, "10");
        long minTime = Long.parseLong(minTimeStr) * 1000;
        float minDistance = Float.parseFloat(minDistanceStr);

        String provider = LocationManager.GPS_PROVIDER;
        if (mLocationManager.getAllProviders().contains(provider)) {
            mLocationManager.requestLocationUpdates(provider, minTime, minDistance, this);

            if (Constants.DEBUG_MODE)
                Log.d(Constants.TAG, "Tracker service request location updates for " + provider);
        }

        provider = LocationManager.NETWORK_PROVIDER;
        if (mLocationManager.getAllProviders().contains(provider)) {
            mLocationManager.requestLocationUpdates(provider, minTime, minDistance, this);

            if (Constants.DEBUG_MODE)
                Log.d(Constants.TAG, "Tracker service request location updates for " + provider);
        }

        NotificationHelper.showLocationInfo(this);

        // there are no tracks or last track correctly ended
        if (mSharedPreferencesTemp.getString(TRACK_URI, null) == null) {
            startTrack();
            mSharedPreferencesTemp.edit().putString(ConstantsUI.TARGET_CLASS, targetActivity).apply();
        } else {
            // looks like service was killed, restore data
            restoreData();
            targetActivity = mSharedPreferencesTemp.getString(ConstantsUI.TARGET_CLASS, "");
        }

        mLocationSenderThread = createLocationSenderThread(minTime);
        mLocationSenderThread.start();

        initTargetIntent(targetActivity);
        addNotification();
    }

    return START_STICKY;
}