diff options
author | Dmitry Donskoy <donskdmitry@mail.ru> | 2018-08-20 20:05:24 +0300 |
---|---|---|
committer | Aleksandr Zatsepin <alexzatsepin@users.noreply.github.com> | 2018-08-22 19:56:21 +0300 |
commit | b5a08c2a218f4d9c57a704eb887bde5319e2b37c (patch) | |
tree | 01e643888a3c3c193c97b27339ddc892761cb6e7 /android/src/com/mapswithme/maps/editor | |
parent | 88d400f2296a4b1a0ec8adb9d505167ca78940a8 (diff) |
[android] Supported api 26 changed intentservices to JobServices, modified problem static instances
Diffstat (limited to 'android/src/com/mapswithme/maps/editor')
-rw-r--r-- | android/src/com/mapswithme/maps/editor/Editor.java | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java index cfccf28b75..bc7daf9fc1 100644 --- a/android/src/com/mapswithme/maps/editor/Editor.java +++ b/android/src/com/mapswithme/maps/editor/Editor.java @@ -1,5 +1,6 @@ package com.mapswithme.maps.editor; +import android.content.Context; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Size; @@ -36,16 +37,6 @@ public final class Editor public static final int MODIFIED = 3; public static final int CREATED = 4; - private static final AppBackgroundTracker.OnTransitionListener sOsmUploader = new AppBackgroundTracker.OnTransitionListener() - { - @Override - public void onTransit(boolean foreground) - { - if (!foreground) - WorkerService.startActionUploadOsmChanges(); - } - }; - private Editor() {} static @@ -55,9 +46,9 @@ public final class Editor private static native void nativeInit(); - public static void init() + public static void init(@NonNull Context context) { - MwmApplication.backgroundTracker().addListener(sOsmUploader); + MwmApplication.backgroundTracker().addListener(new OsmUploadListener(context)); } @WorkerThread @@ -189,4 +180,24 @@ public final class Editor @FeatureStatus public static native int nativeGetMapObjectStatus(); public static native boolean nativeIsMapObjectUploaded(); + + private static class OsmUploadListener implements AppBackgroundTracker.OnTransitionListener + { + @NonNull + private final Context mContext; + + OsmUploadListener(@NonNull Context context) + { + mContext = context.getApplicationContext(); + } + + @Override + public void onTransit(boolean foreground) + { + if (foreground) + return; + + WorkerService.startActionUploadOsmChanges(mContext); + } + } } |