diff options
author | Alexander Zatsepin <az@mapswithme.com> | 2018-04-26 12:29:29 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2018-04-26 14:43:08 +0300 |
commit | 4dfca76c1ca5fcb6f71a09000c61e03a9da2c6b7 (patch) | |
tree | c3dee3badd9590fcf71e72653bed9b3065858e8e /android/src | |
parent | 485845c4cfcd241ba505bc31d96fa934277f276f (diff) |
[android] Added BookmarkInfot to improve performance on bookmarks list
Diffstat (limited to 'android/src')
4 files changed, 67 insertions, 9 deletions
diff --git a/android/src/com/mapswithme/maps/bookmarks/Holders.java b/android/src/com/mapswithme/maps/bookmarks/Holders.java index f9495c1369..d4ea71aded 100644 --- a/android/src/com/mapswithme/maps/bookmarks/Holders.java +++ b/android/src/com/mapswithme/maps/bookmarks/Holders.java @@ -11,7 +11,7 @@ import android.widget.ImageView; import android.widget.TextView; import com.mapswithme.maps.R; -import com.mapswithme.maps.bookmarks.data.Bookmark; +import com.mapswithme.maps.bookmarks.data.BookmarkInfo; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut; import com.mapswithme.maps.bookmarks.data.Track; @@ -214,7 +214,7 @@ public class Holders int pos = position - 1 - (isSectionEmpty(mCategoryId, SECTION_TRACKS) ? 0 : BookmarkManager.INSTANCE.getTracksCount(mCategoryId) + 1); final long bookmarkId = BookmarkManager.INSTANCE.getBookmarkIdByPosition(mCategoryId, pos); - Bookmark bookmark = BookmarkManager.INSTANCE.getBookmark(bookmarkId); + BookmarkInfo bookmark = new BookmarkInfo(mCategoryId, bookmarkId); mName.setText(bookmark.getTitle()); final Location loc = LocationHelper.INSTANCE.getSavedLocation(); if (loc != null) diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java index a3e6977c03..cd8a60695f 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java @@ -12,7 +12,6 @@ import com.mapswithme.maps.ads.LocalAdInfo; import com.mapswithme.maps.routing.RoutePointInfo; import com.mapswithme.maps.search.HotelsFilter; import com.mapswithme.maps.search.PriceFilterView; -import com.mapswithme.maps.taxi.TaxiManager; import com.mapswithme.maps.ugc.UGC; import com.mapswithme.util.Constants; @@ -75,7 +74,7 @@ public class Bookmark extends MapObject super(type, source); mCategoryId = source.readLong(); mBookmarkId = source.readLong(); - mIcon = BookmarkManager.getIconByColor(source.readInt()); + mIcon = BookmarkManager.INSTANCE.getIconByColor(source.readInt()); mMerX = source.readDouble(); mMerY = source.readDouble(); initXY(); @@ -94,7 +93,7 @@ public class Bookmark extends MapObject private Icon getIconInternal() { - return BookmarkManager.getIconByColor(nativeGetColor(mBookmarkId)); + return BookmarkManager.INSTANCE.getIconByColor(nativeGetColor(mBookmarkId)); } public Icon getIcon() @@ -162,11 +161,13 @@ public class Bookmark extends MapObject return getGe0Url(addName).replaceFirst(Constants.Url.GE0_PREFIX, Constants.Url.HTTP_GE0_PREFIX); } - private native String nativeGetBookmarkDescription(@IntRange(from = 0) long bookmarkId); + public static native String nativeGetName(@IntRange(from = 0) long bookmarkId); + + public static native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId); - private native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId); + public static native int nativeGetColor(@IntRange(from = 0) long bookmarkId); - private native int nativeGetColor(@IntRange(from = 0) long bookmarkId); + private native String nativeGetBookmarkDescription(@IntRange(from = 0) long bookmarkId); private native double nativeGetScale(@IntRange(from = 0) long bookmarkId); diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkInfo.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkInfo.java new file mode 100644 index 0000000000..f1e3f599ce --- /dev/null +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkInfo.java @@ -0,0 +1,56 @@ +package com.mapswithme.maps.bookmarks.data; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; + +import com.mapswithme.maps.Framework; + +public class BookmarkInfo +{ + private final long mCategoryId; + private final long mBookmarkId; + @NonNull + private String mTitle; + @NonNull + private Icon mIcon; + private double mMerX; + private double mMerY; + + public BookmarkInfo(@IntRange(from = 0) long categoryId, @IntRange(from = 0) long bookmarkId) + { + mCategoryId = categoryId; + mBookmarkId = bookmarkId; + mTitle = Bookmark.nativeGetName(mBookmarkId); + mIcon = BookmarkManager.INSTANCE.getIconByColor(Bookmark.nativeGetColor(mBookmarkId)); + final ParcelablePointD ll = Bookmark.nativeGetXY(mBookmarkId); + mMerX = ll.x; + mMerY = ll.y; + } + + public long getCategoryId() + { + return mCategoryId; + } + + public long getBookmarkId() + { + return mBookmarkId; + } + + public DistanceAndAzimut getDistanceAndAzimuth(double cLat, double cLon, double north) + { + return Framework.nativeGetDistanceAndAzimuth(mMerX, mMerY, cLat, cLon, north); + } + + @NonNull + public String getTitle() + { + return mTitle; + } + + @NonNull + public Icon getIcon() + { + return mIcon; + } +} diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 34dca9e9a0..a1dee82bbc 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -70,7 +70,8 @@ public enum BookmarkManager ICONS.add(new Icon("placemark-orange", Icon.PREDEFINED_COLOR_ORANGE, R.drawable.ic_bookmark_marker_orange_off, R.drawable.ic_bookmark_marker_orange_on)); } - static Icon getIconByColor(@Icon.PredefinedColor int color) + @NonNull + Icon getIconByColor(@Icon.PredefinedColor int color) { for (Icon icon : ICONS) { |