forked from organicmaps/organicmaps
[android] Added BookmarkInfot to improve performance on bookmarks list
This commit is contained in:
parent
485845c4cf
commit
4dfca76c1c
4 changed files with 68 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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,12 +161,14 @@ public class Bookmark extends MapObject
|
|||
return getGe0Url(addName).replaceFirst(Constants.Url.GE0_PREFIX, Constants.Url.HTTP_GE0_PREFIX);
|
||||
}
|
||||
|
||||
public static native String nativeGetName(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
public static native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
public static native int nativeGetColor(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native String nativeGetBookmarkDescription(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native int nativeGetColor(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native double nativeGetScale(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native String nativeEncode2Ge0Url(@IntRange(from = 0) long bookmarkId, boolean addName);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue