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

BookmarkManager.java « data « bookmarks « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 871b583185a67f9272a8585ed6a683aed2bf01fe (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
package com.mapswithme.maps.bookmarks.data;

import androidx.annotation.IntDef;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.Nullable;

import com.mapswithme.maps.base.DataChangedListener;
import com.mapswithme.maps.base.Observable;
import com.mapswithme.maps.PrivateVariables;
import com.mapswithme.maps.metrics.UserActionsLogger;
import com.mapswithme.util.KeyValue;
import com.mapswithme.util.UTM;
import com.mapswithme.util.statistics.Statistics;

import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@MainThread
public enum BookmarkManager
{
  INSTANCE;

  @Retention(RetentionPolicy.SOURCE)
  @IntDef({ CLOUD_BACKUP, CLOUD_RESTORE })
  public @interface SynchronizationType {}

  public static final int CLOUD_BACKUP = 0;
  public static final int CLOUD_RESTORE = 1;

  @Retention(RetentionPolicy.SOURCE)
  @IntDef({ CLOUD_SUCCESS, CLOUD_AUTH_ERROR, CLOUD_NETWORK_ERROR,
            CLOUD_DISK_ERROR, CLOUD_USER_INTERRUPTED, CLOUD_INVALID_CALL })
  public @interface SynchronizationResult {}

  public static final int CLOUD_SUCCESS = 0;
  public static final int CLOUD_AUTH_ERROR = 1;
  public static final int CLOUD_NETWORK_ERROR = 2;
  public static final int CLOUD_DISK_ERROR = 3;
  public static final int CLOUD_USER_INTERRUPTED = 4;
  public static final int CLOUD_INVALID_CALL = 5;

  @Retention(RetentionPolicy.SOURCE)
  @IntDef({ CLOUD_BACKUP_EXISTS, CLOUD_NO_BACKUP, CLOUD_NOT_ENOUGH_DISK_SPACE })
  public @interface RestoringRequestResult {}

  public static final int CLOUD_BACKUP_EXISTS = 0;
  public static final int CLOUD_NO_BACKUP = 1;
  public static final int CLOUD_NOT_ENOUGH_DISK_SPACE = 2;

  @Retention(RetentionPolicy.SOURCE)
  @IntDef({ SORT_BY_TYPE, SORT_BY_DISTANCE, SORT_BY_TIME })
  public @interface SortingType {}

  public static final int SORT_BY_TYPE = 0;
  public static final int SORT_BY_DISTANCE = 1;
  public static final int SORT_BY_TIME = 2;

  public static final List<Icon> ICONS = new ArrayList<>();

  @NonNull
  private final BookmarkCategoriesDataProvider mCategoriesCoreDataProvider
      = new CoreBookmarkCategoriesDataProvider();

  @NonNull
  private BookmarkCategoriesDataProvider mCurrentDataProvider = mCategoriesCoreDataProvider;

  @NonNull
  private final BookmarkCategoriesCache mBookmarkCategoriesCache
      = new BookmarkManager.BookmarkCategoriesCache();

  @NonNull
  private final List<BookmarksLoadingListener> mListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksSortingListener> mSortingListeners = new ArrayList<>();

  @NonNull
  private final List<KmlConversionListener> mConversionListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksSharingListener> mSharingListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksCloudListener> mCloudListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksCatalogListener> mCatalogListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksCatalogPingListener> mCatalogPingListeners = new ArrayList<>();

  @NonNull
  private final List<BookmarksInvalidCategoriesListener> mInvalidCategoriesListeners = new ArrayList<>();

  static
  {
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_RED, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_PINK, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_PURPLE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_DEEPPURPLE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_BLUE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_LIGHTBLUE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_CYAN, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_TEAL, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_GREEN, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_LIME, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_YELLOW, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_ORANGE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_DEEPORANGE, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_BROWN, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_GRAY, Icon.BOOKMARK_ICON_TYPE_NONE));
    ICONS.add(new Icon(Icon.PREDEFINED_COLOR_BLUEGRAY, Icon.BOOKMARK_ICON_TYPE_NONE));
  }

  public void toggleCategoryVisibility(long catId)
  {
    boolean isVisible = isVisible(catId);
    setVisibility(catId, !isVisible);
  }

  public Bookmark addNewBookmark(double lat, double lon)
  {
    final Bookmark bookmark = nativeAddBookmarkToLastEditedCategory(lat, lon);
    UserActionsLogger.logAddToBookmarkEvent();
    Statistics.INSTANCE.trackBookmarkCreated();
    return bookmark;
  }

  public void addLoadingListener(@NonNull BookmarksLoadingListener listener)
  {
    mListeners.add(listener);
  }

  public void removeLoadingListener(@NonNull BookmarksLoadingListener listener)
  {
    mListeners.remove(listener);
  }

  public void addSortingListener(@NonNull BookmarksSortingListener listener)
  {
    mSortingListeners.add(listener);
  }

  public void removeSortingListener(@NonNull BookmarksSortingListener listener)
  {
    mSortingListeners.remove(listener);
  }

  public void addKmlConversionListener(@NonNull KmlConversionListener listener)
  {
    mConversionListeners.add(listener);
  }

  public void removeKmlConversionListener(@NonNull KmlConversionListener listener)
  {
    mConversionListeners.remove(listener);
  }

  public void addSharingListener(@NonNull BookmarksSharingListener listener)
  {
    mSharingListeners.add(listener);
  }

  public void removeSharingListener(@NonNull BookmarksSharingListener listener)
  {
    mSharingListeners.remove(listener);
  }

  public void addCloudListener(@NonNull BookmarksCloudListener listener)
  {
    mCloudListeners.add(listener);
  }

  public void removeCloudListener(@NonNull BookmarksCloudListener listener)
  {
    mCloudListeners.remove(listener);
  }

  public void addCatalogListener(@NonNull BookmarksCatalogListener listener)
  {
    mCatalogListeners.add(listener);
  }

  public void removeCatalogListener(@NonNull BookmarksCatalogListener listener)
  {
    mCatalogListeners.remove(listener);
  }

  public void addInvalidCategoriesListener(@NonNull BookmarksInvalidCategoriesListener listener)
  {
    mInvalidCategoriesListeners.add(listener);
  }

  public void removeInvalidCategoriesListener(@NonNull BookmarksInvalidCategoriesListener listener)
  {
    mInvalidCategoriesListeners.remove(listener);
  }

  public void addCatalogPingListener(@NonNull BookmarksCatalogPingListener listener)
  {
    mCatalogPingListeners.add(listener);
  }

  public void removeCatalogPingListener(@NonNull BookmarksCatalogPingListener listener)
  {
    mCatalogPingListeners.remove(listener);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksChanged()
  {
    updateCache();
  }

  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksLoadingStarted()
  {
    for (BookmarksLoadingListener listener : mListeners)
      listener.onBookmarksLoadingStarted();
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksLoadingFinished()
  {
    updateCache();
    mCurrentDataProvider = new CacheBookmarkCategoriesDataProvider();
    for (BookmarksLoadingListener listener : mListeners)
      listener.onBookmarksLoadingFinished();
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksSortingCompleted(@NonNull SortedBlock[] sortedBlocks, long timestamp)
  {
    for (BookmarksSortingListener listener : mSortingListeners)
      listener.onBookmarksSortingCompleted(sortedBlocks, timestamp);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksSortingCancelled(long timestamp)
  {
    for (BookmarksSortingListener listener : mSortingListeners)
      listener.onBookmarksSortingCancelled(timestamp);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onBookmarksFileLoaded(boolean success, @NonNull String fileName,
                                    boolean isTemporaryFile)
  {
    // Android could create temporary file with bookmarks in some cases (KML/KMZ file is a blob
    // in the intent, so we have to create a temporary file on the disk). Here we can delete it.
    if (isTemporaryFile)
    {
      File tmpFile = new File(fileName);
      tmpFile.delete();
    }

    for (BookmarksLoadingListener listener : mListeners)
      listener.onBookmarksFileLoaded(success);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onFinishKmlConversion(boolean success)
  {
    for (KmlConversionListener listener : mConversionListeners)
      listener.onFinishKmlConversion(success);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onPreparedFileForSharing(BookmarkSharingResult result)
  {
    for (BookmarksSharingListener listener : mSharingListeners)
      listener.onPreparedFileForSharing(result);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onSynchronizationStarted(@SynchronizationType int type)
  {
    for (BookmarksCloudListener listener : mCloudListeners)
      listener.onSynchronizationStarted(type);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onSynchronizationFinished(@SynchronizationType int type,
                                        @SynchronizationResult int result,
                                        @NonNull String errorString)
  {
    for (BookmarksCloudListener listener : mCloudListeners)
      listener.onSynchronizationFinished(type, result, errorString);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onRestoreRequested(@RestoringRequestResult int result, @NonNull String deviceName,
                                 long backupTimestampInMs)
  {
    for (BookmarksCloudListener listener : mCloudListeners)
      listener.onRestoreRequested(result, deviceName, backupTimestampInMs);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onRestoredFilesPrepared()
  {
    for (BookmarksCloudListener listener : mCloudListeners)
      listener.onRestoredFilesPrepared();
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onImportStarted(@NonNull String id)
  {
    for (BookmarksCatalogListener listener : mCatalogListeners)
      listener.onImportStarted(id);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onImportFinished(@NonNull String id, long catId, boolean successful)
  {
    if (successful)
      Statistics.INSTANCE.trackPurchaseProductDelivered(id, PrivateVariables.bookmarksVendor());
    for (BookmarksCatalogListener listener : mCatalogListeners)
      listener.onImportFinished(id, catId, successful);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onTagsReceived(boolean successful, @NonNull CatalogTagsGroup[] tagsGroups,
                             int maxTagsCount)
  {
    List<CatalogTagsGroup> unmodifiableData = Collections.unmodifiableList(Arrays.asList(tagsGroups));
    for (BookmarksCatalogListener listener : mCatalogListeners)
    {
      listener.onTagsReceived(successful, unmodifiableData, maxTagsCount);
    }
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onCustomPropertiesReceived(boolean successful,
                                         @NonNull CatalogCustomProperty[] properties)
  {
    List<CatalogCustomProperty> unmodifiableProperties = Collections.unmodifiableList(Arrays.asList(properties));
    for (BookmarksCatalogListener listener : mCatalogListeners)
      listener.onCustomPropertiesReceived(successful, unmodifiableProperties);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onUploadStarted(long originCategoryId)
  {
    for (BookmarksCatalogListener listener : mCatalogListeners)
      listener.onUploadStarted(originCategoryId);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onUploadFinished(int index, @NonNull String description,
                               long originCategoryId, long resultCategoryId)
  {
    UploadResult result = UploadResult.values()[index];
    for (BookmarksCatalogListener listener : mCatalogListeners)
    {
      listener.onUploadFinished(result, description, originCategoryId, resultCategoryId);
    }
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onPingFinished(boolean isServiceAvailable)
  {
    for (BookmarksCatalogPingListener listener : mCatalogPingListeners)
      listener.onPingFinished(isServiceAvailable);
  }

  // Called from JNI.
  @SuppressWarnings("unused")
  @MainThread
  public void onCheckInvalidCategories(boolean hasInvalidCategories)
  {
    for (BookmarksInvalidCategoriesListener listener : mInvalidCategoriesListeners)
      listener.onCheckInvalidCategories(hasInvalidCategories);
  }

  public boolean isVisible(long catId)
  {
    return nativeIsVisible(catId);
  }

  public void setVisibility(long catId, boolean visible)
  {
    nativeSetVisibility(catId, visible);
  }

  public void setCategoryName(long catId, @NonNull String name)
  {
    nativeSetCategoryName(catId, name);
  }

  public void setCategoryDescription(long id, @NonNull String categoryDesc)
  {
    nativeSetCategoryDescription(id, categoryDesc);
  }

  public void setCategoryTags(@NonNull BookmarkCategory category, @NonNull List<CatalogTag> tags)
  {
    String[] ids = new String[tags.size()];
    for (int i = 0; i < tags.size(); i++)
    {
      ids[i] = tags.get(i).getId();
    }
    nativeSetCategoryTags(category.getId(), ids);
  }

  public void setCategoryProperties(@NonNull BookmarkCategory category,
                                    @NonNull List<CatalogPropertyOptionAndKey> properties)
  {
    for (CatalogPropertyOptionAndKey each : properties)
    {
      nativeSetCategoryCustomProperty(category.getId(), each.getKey(), each.getOption().getValue());
    }
  }

  public void setAccessRules(long id, @NonNull BookmarkCategory.AccessRules rules)
  {
    nativeSetCategoryAccessRules(id, rules.ordinal());
  }

  public void uploadToCatalog(@NonNull BookmarkCategory.AccessRules rules, @NonNull BookmarkCategory category)
  {
    nativeUploadToCatalog(rules.ordinal(), category.getId());
  }

  @NonNull
  public Bookmark updateBookmarkPlacePage(long bmkId)
  {
    return nativeUpdateBookmarkPlacePage(bmkId);
  }

  @Nullable
  public BookmarkInfo getBookmarkInfo(long bmkId)
  {
    return nativeGetBookmarkInfo(bmkId);
  }

  public long getBookmarkIdByPosition(long catId, int positionInCategory)
  {
    return nativeGetBookmarkIdByPosition(catId, positionInCategory);
  }

  @NonNull
  public Track getTrack(long trackId)
  {
    return nativeGetTrack(trackId, Track.class);
  }

  public long getTrackIdByPosition(long catId, int positionInCategory)
  {
    return nativeGetTrackIdByPosition(catId, positionInCategory);
  }

  public static void loadBookmarks() { nativeLoadBookmarks(); }

  public void deleteCategory(long catId) { nativeDeleteCategory(catId); }

  public void deleteTrack(long trackId)
  {
    nativeDeleteTrack(trackId);
  }

  public void deleteBookmark(long bmkId)
  {
    nativeDeleteBookmark(bmkId);
  }

  public long createCategory(@NonNull String name) { return nativeCreateCategory(name); }

  public void showBookmarkOnMap(long bmkId) { nativeShowBookmarkOnMap(bmkId); }

  public void showBookmarkCategoryOnMap(long catId) { nativeShowBookmarkCategoryOnMap(catId); }

  public long getLastEditedCategory() { return nativeGetLastEditedCategory(); }

  @Icon.PredefinedColor
  public int getLastEditedColor() { return nativeGetLastEditedColor(); }

  public void setCloudEnabled(boolean enabled) { nativeSetCloudEnabled(enabled); }

  public boolean isCloudEnabled() { return nativeIsCloudEnabled(); }

  public long getLastSynchronizationTimestampInMs()
  {
    return nativeGetLastSynchronizationTimestampInMs();
  }

  public void loadKmzFile(@NonNull String path, boolean isTemporaryFile)
  {
    nativeLoadKmzFile(path, isTemporaryFile);
  }

  public boolean isAsyncBookmarksLoadingInProgress()
  {
    return nativeIsAsyncBookmarksLoadingInProgress();
  }

  @NonNull
  public AbstractCategoriesSnapshot.Default getDownloadedCategoriesSnapshot()
  {
    List<BookmarkCategory> items = mCurrentDataProvider.getCategories();
    return new AbstractCategoriesSnapshot.Default(items, new FilterStrategy.Downloaded());
  }

  @NonNull
  public AbstractCategoriesSnapshot.Default getOwnedCategoriesSnapshot()
  {
    List<BookmarkCategory> items = mCurrentDataProvider.getCategories();
    return new AbstractCategoriesSnapshot.Default(items, new FilterStrategy.Private());
  }

  @NonNull
  public AbstractCategoriesSnapshot.Default getAllCategoriesSnapshot()
  {
    List<BookmarkCategory> items = mCurrentDataProvider.getCategories();
    return new AbstractCategoriesSnapshot.Default(items, new FilterStrategy.All());
  }

  @NonNull
  public AbstractCategoriesSnapshot.Default getCategoriesSnapshot(FilterStrategy strategy)
  {
    List<BookmarkCategory> items = mCurrentDataProvider.getCategories();
    return new AbstractCategoriesSnapshot.Default(items, strategy);
  }

  @NonNull
  BookmarkCategoriesCache getBookmarkCategoriesCache()
  {
    return mBookmarkCategoriesCache;
  }

  private void updateCache()
  {
    getBookmarkCategoriesCache().update(mCategoriesCoreDataProvider.getCategories());
  }

  public void addCategoriesUpdatesListener(@NonNull DataChangedListener listener)
  {
    getBookmarkCategoriesCache().registerListener(listener);
  }

  public void removeCategoriesUpdatesListener(@NonNull DataChangedListener listener)
  {
    getBookmarkCategoriesCache().unregisterListener(listener);
  }

  @NonNull
  public BookmarkCategory getCategoryById(long categoryId)
  {
    return mCurrentDataProvider.getCategoryById(categoryId);
  }

  public boolean isUsedCategoryName(@NonNull String name)
  {
    return nativeIsUsedCategoryName(name);
  }

  public boolean isEditableBookmark(long bmkId) { return nativeIsEditableBookmark(bmkId); }

  public boolean isEditableTrack(long trackId) { return nativeIsEditableTrack(trackId); }

  public boolean isEditableCategory(long catId) { return nativeIsEditableCategory(catId); }

  public boolean isSearchAllowed(long catId) { return nativeIsSearchAllowed(catId); }

  public void prepareForSearch(long catId) { nativePrepareForSearch(catId); }

  public boolean areAllCategoriesVisible(BookmarkCategory.Type type)
  {
    return nativeAreAllCategoriesVisible(type.ordinal());
  }

  public boolean areAllCategoriesInvisible(BookmarkCategory.Type type)
  {
    return nativeAreAllCategoriesInvisible(type.ordinal());
  }

  public boolean areAllCatalogCategoriesInvisible()
  {
    return areAllCategoriesInvisible(BookmarkCategory.Type.DOWNLOADED);
  }

  public boolean areAllOwnedCategoriesInvisible()
  {
    return areAllCategoriesInvisible(BookmarkCategory.Type.PRIVATE);
  }

  public void setAllCategoriesVisibility(boolean visible, @NonNull BookmarkCategory.Type type)
  {
    nativeSetAllCategoriesVisibility(visible, type.ordinal());
  }

  public int getKmlFilesCountForConversion()
  {
    return nativeGetKmlFilesCountForConversion();
  }

  public void convertAllKmlFiles()
  {
    nativeConvertAllKmlFiles();
  }

  public void prepareFileForSharing(long catId)
  {
    nativePrepareFileForSharing(catId);
  }

  public boolean isCategoryEmpty(long catId)
  {
    return nativeIsCategoryEmpty(catId);
  }

  public void prepareCategoryForSharing(long catId)
  {
    nativePrepareFileForSharing(catId);
  }

  public void requestRestoring()
  {
    nativeRequestRestoring();
  }

  public void applyRestoring()
  {
    nativeApplyRestoring();
  }

  public void cancelRestoring()
  {
    nativeCancelRestoring();
  }

  public void setNotificationsEnabled(boolean enabled)
  {
    nativeSetNotificationsEnabled(enabled);
  }

  public boolean areNotificationsEnabled()
  {
    return nativeAreNotificationsEnabled();
  }

  public void importFromCatalog(@NonNull String serverId, @NonNull String filePath)
  {
    nativeImportFromCatalog(serverId, filePath);
  }

  public void uploadRoutes(int accessRules, @NonNull BookmarkCategory bookmarkCategory)
  {
    nativeUploadToCatalog(accessRules, bookmarkCategory.getId());
  }

  @NonNull
  public String getCatalogDeeplink(long catId)
  {
    return nativeGetCatalogDeeplink(catId);
  }

  @NonNull
  public String getCatalogPublicLink(long catId)
  {
    return nativeGetCatalogPublicLink(catId);
  }

  @NonNull
  public String getCatalogDownloadUrl(@NonNull String serverId)
  {
    return nativeGetCatalogDownloadUrl(serverId);
  }

  @NonNull
  public String getWebEditorUrl(@NonNull String serverId)
  {
    return nativeGetWebEditorUrl(serverId);
  }

  @NonNull
  public String getCatalogFrontendUrl(@UTM.UTMType int utm)
  {
    return nativeGetCatalogFrontendUrl(utm);
  }

  @NonNull
  public KeyValue[] getCatalogHeaders()
  {
    return nativeGetCatalogHeaders();
  }

  @NonNull
  public String injectCatalogUTMContent(@NonNull String url,  @UTM.UTMContentType int content)
  {
    return nativeInjectCatalogUTMContent(url, content);
  }

  @NonNull
  public String getGuidesIds()
  {
    return nativeGuidesIds();
  }

  public boolean isGuide(@NonNull BookmarkCategory category)
  {
    return category.isFromCatalog() && nativeIsGuide(category.getAccessRules().ordinal());
  }

  public void requestRouteTags()
  {
    nativeRequestCatalogTags();
  }

  public void requestCustomProperties()
  {
    nativeRequestCatalogCustomProperties();
  }

  public void pingBookmarkCatalog()
  {
    nativePingBookmarkCatalog();
  }

  public void checkInvalidCategories()
  {
    nativeCheckInvalidCategories();
  }

  public void deleteInvalidCategories()
  {
    nativeDeleteInvalidCategories();
  }

  public void resetInvalidCategories()
  {
    nativeResetInvalidCategories();
  }

  public boolean isCategoryFromCatalog(long catId)
  {
    return nativeIsCategoryFromCatalog(catId);
  }

  public boolean hasLastSortingType(long catId) { return nativeHasLastSortingType(catId); }

  @SortingType
  public int getLastSortingType(long catId) { return nativeGetLastSortingType(catId); }

  public void setLastSortingType(long catId, @SortingType int sortingType)
  {
    nativeSetLastSortingType(catId, sortingType);
  }

  public void resetLastSortingType(long catId) { nativeResetLastSortingType(catId); }

  @NonNull
  @SortingType
  public int[] getAvailableSortingTypes(long catId, boolean hasMyPosition)
  {
    return nativeGetAvailableSortingTypes(catId, hasMyPosition);
  }

  public void getSortedCategory(long catId, @SortingType int sortingType,
                                boolean hasMyPosition, double lat, double lon,
                                long timestamp)
  {
    nativeGetSortedCategory(catId, sortingType, hasMyPosition, lat, lon, timestamp);
  }

  native BookmarkCategory[] nativeGetBookmarkCategories();


  @NonNull
  public String getBookmarkName(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkName(bookmarkId);
  }

  @NonNull
  public String getBookmarkFeatureType(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkFeatureType(bookmarkId);
  }

  @NonNull
  public ParcelablePointD getBookmarkXY(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkXY(bookmarkId);
  }

  @Icon.PredefinedColor
  public int getBookmarkColor(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkColor(bookmarkId);
  }

  @Icon.BookmarkIconType
  public int getBookmarkIcon(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkIcon(bookmarkId);
  }

  @NonNull
  public String getBookmarkDescription(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkDescription(bookmarkId);
  }

  public double getBookmarkScale(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkScale(bookmarkId);
  }

  @NonNull
  public String encode2Ge0Url(@IntRange(from = 0) long bookmarkId, boolean addName)
  {
    return nativeEncode2Ge0Url(bookmarkId, addName);
  }

  public void setBookmarkParams(@IntRange(from = 0) long bookmarkId, @NonNull String name,
                                @Icon.PredefinedColor int color, @NonNull String descr)
  {
    nativeSetBookmarkParams(bookmarkId, name, color, descr);
  }

  public void changeBookmarkCategory(@IntRange(from = 0) long oldCatId,
                                     @IntRange(from = 0) long newCatId,
                                     @IntRange(from = 0) long bookmarkId)
  {
    nativeChangeBookmarkCategory(oldCatId, newCatId, bookmarkId);
  }

  @NonNull
  public String getBookmarkAddress(@IntRange(from = 0) long bookmarkId)
  {
    return nativeGetBookmarkAddress(bookmarkId);
  }

  public void notifyCategoryChanging(@NonNull BookmarkInfo bookmarkInfo,
                                     @IntRange(from = 0) long catId)
  {
    if (catId == bookmarkInfo.getCategoryId())
      return;

    changeBookmarkCategory(bookmarkInfo.getCategoryId(), catId, bookmarkInfo.getBookmarkId());
  }

  public void notifyCategoryChanging(@NonNull Bookmark bookmark, @IntRange(from = 0) long catId)
  {
    if (catId == bookmark.getCategoryId())
      return;

    changeBookmarkCategory(bookmark.getCategoryId(), catId, bookmark.getBookmarkId());
  }

  public void notifyParametersUpdating(@NonNull BookmarkInfo bookmarkInfo, @NonNull String name,
                                       @Nullable Icon icon, @NonNull String description)
  {
    if (icon == null)
      icon = bookmarkInfo.getIcon();

    if (!name.equals(bookmarkInfo.getName()) || !icon.equals(bookmarkInfo.getIcon()) ||
        !description.equals(getBookmarkDescription(bookmarkInfo.getBookmarkId())))
    {
      setBookmarkParams(bookmarkInfo.getBookmarkId(), name, icon.getColor(), description);
    }
  }

  public void notifyParametersUpdating(@NonNull Bookmark bookmark, @NonNull String name,
                                       @Nullable Icon icon, @NonNull String description)
  {
    if (icon == null)
      icon = bookmark.getIcon();

    if (!name.equals(bookmark.getName()) || !icon.equals(bookmark.getIcon()) ||
        !description.equals(getBookmarkDescription(bookmark.getBookmarkId())))
    {
      setBookmarkParams(bookmark.getBookmarkId(), name,
                        icon != null ? icon.getColor() : getLastEditedColor(), description);
    }
  }

  private native int nativeGetCategoriesCount();

  private native int nativeGetCategoryPositionById(long catId);

  private native long nativeGetCategoryIdByPosition(int position);

  private native int nativeGetBookmarksCount(long catId);

  private native int nativeGetTracksCount(long catId);

  @NonNull
  private native Bookmark nativeUpdateBookmarkPlacePage(long bmkId);

  @Nullable
  private native BookmarkInfo nativeGetBookmarkInfo(long bmkId);

  private native long nativeGetBookmarkIdByPosition(long catId, int position);

  @NonNull
  private native Track nativeGetTrack(long trackId, Class<Track> trackClazz);

  private native long nativeGetTrackIdByPosition(long catId, int position);

  private native boolean nativeIsVisible(long catId);

  private native void nativeSetVisibility(long catId, boolean visible);

  private native void nativeSetCategoryName(long catId, @NonNull String n);

  private native void nativeSetCategoryDescription(long catId, @NonNull String desc);

  private native void nativeSetCategoryTags(long catId, @NonNull String[] tagsIds);

  private native void nativeSetCategoryAccessRules(long catId, int accessRules);

  private native void nativeSetCategoryCustomProperty(long catId, String key, String value);

  private static native void nativeLoadBookmarks();

  private native boolean nativeDeleteCategory(long catId);

  private native void nativeDeleteTrack(long trackId);

  private native void nativeDeleteBookmark(long bmkId);

  /**
   * @return category Id
   */
  private native long nativeCreateCategory(@NonNull String name);

  private native void nativeShowBookmarkOnMap(long bmkId);

  private native void nativeShowBookmarkCategoryOnMap(long catId);

  @NonNull
  private native Bookmark nativeAddBookmarkToLastEditedCategory(double lat, double lon);

  private native long nativeGetLastEditedCategory();

  @Icon.PredefinedColor
  private native int nativeGetLastEditedColor();

  private native void nativeSetCloudEnabled(boolean enabled);

  private native boolean nativeIsCloudEnabled();

  private native long nativeGetLastSynchronizationTimestampInMs();

  private static native void nativeLoadKmzFile(@NonNull String path, boolean isTemporaryFile);

  private static native boolean nativeIsAsyncBookmarksLoadingInProgress();

  private static native boolean nativeIsUsedCategoryName(@NonNull String name);

  private static native boolean nativeIsEditableBookmark(long bmkId);

  private static native boolean nativeIsEditableTrack(long trackId);

  private static native boolean nativeIsEditableCategory(long catId);

  private static native boolean nativeIsSearchAllowed(long catId);

  private static native void nativePrepareForSearch(long catId);

  private static native boolean nativeAreAllCategoriesVisible(int type);

  private static native boolean nativeAreAllCategoriesInvisible(int type);

  private static native void nativeSetAllCategoriesVisibility(boolean visible, int type);

  private static native int nativeGetKmlFilesCountForConversion();

  private static native void nativeConvertAllKmlFiles();

  private static native void nativePrepareFileForSharing(long catId);

  private static native boolean nativeIsCategoryEmpty(long catId);

  private static native void nativeRequestRestoring();

  private static native void nativeApplyRestoring();

  private static native void nativeCancelRestoring();

  private static native void nativeSetNotificationsEnabled(boolean enabled);

  private static native boolean nativeAreNotificationsEnabled();

  private static native void nativeImportFromCatalog(@NonNull String serverId,
                                                     @NonNull String filePath);

  private static native void nativeUploadToCatalog(int accessRules,
                                                   long catId);

  @NonNull
  private static native String nativeGetCatalogDeeplink(long catId);

  @NonNull
  private static native String nativeGetCatalogPublicLink(long catId);

  @NonNull
  private static native String nativeGetCatalogDownloadUrl(@NonNull String serverId);

  @NonNull
  private static native String nativeGetWebEditorUrl(@NonNull String serverId);

  @NonNull
  private static native String nativeGetCatalogFrontendUrl(@UTM.UTMType int utm);

  @NonNull
  private static native KeyValue[] nativeGetCatalogHeaders();

  @NonNull
  private static native String nativeInjectCatalogUTMContent(@NonNull String url,
                                                             @UTM.UTMContentType int content);

  private static native boolean nativeIsCategoryFromCatalog(long catId);

  private static native void nativeRequestCatalogTags();

  private static native void nativeRequestCatalogCustomProperties();

  private static native void nativePingBookmarkCatalog();

  private static native void nativeCheckInvalidCategories();
  private static native void nativeDeleteInvalidCategories();
  private static native void nativeResetInvalidCategories();

  private native boolean nativeHasLastSortingType(long catId);

  @SortingType
  private native int nativeGetLastSortingType(long catId);

  private native void nativeSetLastSortingType(long catId, @SortingType int sortingType);

  private native void nativeResetLastSortingType(long catId);

  @NonNull
  @SortingType
  private native int[] nativeGetAvailableSortingTypes(long catId, boolean hasMyPosition);

  private native boolean nativeGetSortedCategory(long catId, @SortingType int sortingType,
                                                 boolean hasMyPosition, double lat, double lon,
                                                 long timestamp);

  @NonNull
  private static native String nativeGuidesIds();
  private static native boolean nativeIsGuide(int accessRulesIndex);

  @NonNull
  private static native String nativeGetBookmarkName(@IntRange(from = 0) long bookmarkId);

  @NonNull
  private static native String nativeGetBookmarkFeatureType(@IntRange(from = 0) long bookmarkId);

  @NonNull
  private static native ParcelablePointD nativeGetBookmarkXY(@IntRange(from = 0) long bookmarkId);

  @Icon.PredefinedColor
  private static native int nativeGetBookmarkColor(@IntRange(from = 0) long bookmarkId);

  @Icon.BookmarkIconType
  private static native int nativeGetBookmarkIcon(@IntRange(from = 0) long bookmarkId);

  @NonNull
  private static native String nativeGetBookmarkDescription(@IntRange(from = 0) long bookmarkId);

  private static native double nativeGetBookmarkScale(@IntRange(from = 0) long bookmarkId);

  @NonNull
  private static native String nativeEncode2Ge0Url(@IntRange(from = 0) long bookmarkId,
                                                   boolean addName);

  private static native void nativeSetBookmarkParams(@IntRange(from = 0) long bookmarkId,
                                                     @NonNull String name,
                                                     @Icon.PredefinedColor int color,
                                                     @NonNull String descr);

  private static native void nativeChangeBookmarkCategory(@IntRange(from = 0) long oldCatId,
                                                          @IntRange(from = 0) long newCatId,
                                                          @IntRange(from = 0) long bookmarkId);

  @NonNull
  private static native String nativeGetBookmarkAddress(@IntRange(from = 0) long bookmarkId);

  public interface BookmarksLoadingListener
  {
    void onBookmarksLoadingStarted();
    void onBookmarksLoadingFinished();
    void onBookmarksFileLoaded(boolean success);
  }

  public interface BookmarksSortingListener
  {
    void onBookmarksSortingCompleted(@NonNull SortedBlock[] sortedBlocks, long timestamp);
    void onBookmarksSortingCancelled(long timestamp);
  }

  public interface KmlConversionListener
  {
    void onFinishKmlConversion(boolean success);
  }

  public interface BookmarksSharingListener
  {
    void onPreparedFileForSharing(@NonNull BookmarkSharingResult result);
  }

  public interface BookmarksCloudListener
  {
    /**
     * The method is called when the synchronization started.
     *
     * @param type determines type of synchronization (backup or restoring).
     */
    void onSynchronizationStarted(@SynchronizationType int type);

    /**
     * The method is called when the synchronization finished.
     *
     * @param type determines type of synchronization (backup or restoring).
     * @param result is one of possible results of the synchronization.
     * @param errorString contains detailed description in case of unsuccessful completion.
     */
    void onSynchronizationFinished(@SynchronizationType int type,
                                   @SynchronizationResult int result,
                                   @NonNull String errorString);

    /**
     * The method is called after restoring request.
     *
     * @param result By result you can determine if the restoring is possible.
     * @param deviceName The name of device which was the source of the backup.
     * @param backupTimestampInMs contains timestamp of the backup on the server (in milliseconds).
     */
    void onRestoreRequested(@RestoringRequestResult int result, @NonNull String deviceName,
                            long backupTimestampInMs);

    /**
     * Restored bookmark files are prepared to substitute for the current ones.
     * After this callback any cached bookmarks data become invalid. Also after this
     * callback the restoring process can not be cancelled.
     */
    void onRestoredFilesPrepared();
  }

  public interface BookmarksCatalogPingListener
  {
    void onPingFinished(boolean isServiceAvailable);
  }

  public interface BookmarksInvalidCategoriesListener
  {
    void onCheckInvalidCategories(boolean hasInvalidCategories);
  }

  public interface BookmarksCatalogListener
  {
    /**
     * The method is called when the importing of a file from the catalog is started.
     *
     * @param serverId is server identifier of the file.
     */
    void onImportStarted(@NonNull String serverId);

    /**
     * The method is called when the importing of a file from the catalog is finished.
     *
     * @param serverId is server identifier of the file.
     * @param catId is client identifier of the created bookmarks category.
     * @param successful is result of the importing.
     */
    void onImportFinished(@NonNull String serverId, long catId, boolean successful);

    /**
     * The method is called when the tags were received from the server.
     * @param successful is the result of the receiving.
     * @param tagsGroups is the tags collection.
     */
    void onTagsReceived(boolean successful, @NonNull List<CatalogTagsGroup> tagsGroups, int tagsLimit);

    /**
     * The method is called when the custom properties were received from the server.
     *  @param successful is the result of the receiving.
     * @param properties is the properties collection.
     */
    void onCustomPropertiesReceived(boolean successful,
                                    @NonNull List<CatalogCustomProperty> properties);

    /**
     * The method is called when the uploading to the catalog is started.
     *
     * @param originCategoryId is identifier of the uploading bookmarks category.
     */
    void onUploadStarted(long originCategoryId);

    /**
     * The method is called when the uploading to the catalog is finished.
     *  @param uploadResult is result of the uploading.
     * @param description is detailed description of the uploading result.
     * @param originCategoryId is original identifier of the uploaded bookmarks category.
     * @param resultCategoryId is identifier of the uploaded category after finishing.
*                         In the case of bookmarks modification during uploading
     */
    void onUploadFinished(@NonNull UploadResult uploadResult, @NonNull String description,
                          long originCategoryId, long resultCategoryId);
  }

  public static class DefaultBookmarksCatalogListener implements BookmarksCatalogListener
  {
    @Override
    public void onImportStarted(@NonNull String serverId)
    {
      /* do noting by default */
    }

    @Override
    public void onImportFinished(@NonNull String serverId, long catId, boolean successful)
    {
      /* do noting by default */
    }

    @Override
    public void onTagsReceived(boolean successful, @NonNull List<CatalogTagsGroup> tagsGroups,
                               int tagsLimit)
    {
      /* do noting by default */
    }

    @Override
    public void onCustomPropertiesReceived(boolean successful,
                                           @NonNull List<CatalogCustomProperty> properties)
    {
      /* do noting by default */
    }

    @Override
    public void onUploadStarted(long originCategoryId)
    {
      /* do noting by default */
    }

    @Override
    public void onUploadFinished(@NonNull UploadResult uploadResult, @NonNull String description,
                                 long originCategoryId, long resultCategoryId)
    {
      /* do noting by default */
    }
  }

  public enum UploadResult
  {
    UPLOAD_RESULT_SUCCESS,
    UPLOAD_RESULT_NETWORK_ERROR,
    UPLOAD_RESULT_SERVER_ERROR,
    UPLOAD_RESULT_AUTH_ERROR,
    /* Broken file */
    UPLOAD_RESULT_MALFORMED_DATA_ERROR,
    /* Edit on web */
    UPLOAD_RESULT_ACCESS_ERROR,
    UPLOAD_RESULT_INVALID_CALL;
  }

  static class BookmarkCategoriesCache extends Observable<DataChangedListener>
  {
    @NonNull
    private final List<BookmarkCategory> mCategories = new ArrayList<>();

    void update(@NonNull List<BookmarkCategory> categories)
    {
      mCategories.clear();
      mCategories.addAll(categories);
      notifyChanged();
    }

    @NonNull
    public List<BookmarkCategory> getCategories()
    {
      return Collections.unmodifiableList(mCategories);
    }
  }
}