forked from organicmaps/organicmaps
[AND] Use circles for bookmarks, layout impr.
This commit is contained in:
parent
77e2da9634
commit
bbbcebc7c6
6 changed files with 41 additions and 19 deletions
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="3dp"
|
||||
android:paddingRight="3dp" >
|
||||
|
||||
|
@ -11,7 +12,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:src="@drawable/placemark_red" />
|
||||
|
||||
<TextView
|
||||
|
@ -23,8 +27,7 @@
|
|||
android:layout_toRightOf="@id/pi_pin_color"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/Holo.TextAppearance.Large.Light"
|
||||
android:textColor="@color/text_primary"
|
||||
/>
|
||||
android:textColor="@color/text_primary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pi_distance"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="3dp"
|
||||
android:paddingRight="3dp" >
|
||||
|
||||
|
@ -11,12 +12,16 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:src="@drawable/placemark_red" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@+id/pi_pin_color"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<resources>
|
||||
|
||||
<dimen name="icon_size">24dp</dimen>
|
||||
<dimen name="circle_size">16dp</dimen>
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="margin_tiny">4dp</dimen>
|
||||
|
|
|
@ -86,7 +86,7 @@ public class MapObjectFragment extends Fragment
|
|||
|
||||
setTexts(bookmark.getName(), null , bookmark.getCategoryName(getActivity()), bookmark.getBookmarkDescription(), bookmark.getLat(), bookmark.getLon());
|
||||
|
||||
final int circleSize = (int) (getResources().getDimension(R.dimen.margin_medium) + .5);
|
||||
final int circleSize = (int) (getResources().getDimension(R.dimen.circle_size) + .5);
|
||||
final Drawable icon = UiUtils.drawCircleForPin(bookmark.getIcon().getType(), circleSize, getResources());
|
||||
|
||||
mGroupTV.setCompoundDrawables(UiUtils
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
|
@ -31,6 +33,9 @@ public class BookmarkListAdapter extends BaseAdapter
|
|||
private double mNorth = -1;
|
||||
private final LocationService mLocation;
|
||||
|
||||
// reuse drawables
|
||||
private final Map<String, Drawable> mBmkToCircle = new HashMap<String, Drawable>(8);
|
||||
|
||||
public BookmarkListAdapter(Activity context, LocationService location,
|
||||
BookmarkCategory cat)
|
||||
{
|
||||
|
@ -210,13 +215,28 @@ public class BookmarkListAdapter extends BaseAdapter
|
|||
|
||||
void setIcon(Bookmark bmk)
|
||||
{
|
||||
icon.setImageBitmap(bmk.getIcon().getIcon());
|
||||
final String key = bmk.getIcon().getType();
|
||||
Drawable circle = null;
|
||||
|
||||
if (!mBmkToCircle.containsKey(key))
|
||||
{
|
||||
final Resources res = mContext.getResources();
|
||||
final int circleSize = (int) (res.getDimension(R.dimen.circle_size) + .5);
|
||||
circle = UiUtils.drawCircleForPin(key, circleSize, res);
|
||||
mBmkToCircle.put(key, circle);
|
||||
}
|
||||
else
|
||||
circle = mBmkToCircle.get(key);
|
||||
|
||||
icon.setImageDrawable(circle);
|
||||
}
|
||||
|
||||
void setIcon(Track trk)
|
||||
{
|
||||
final Resources res = mContext.getResources();
|
||||
final Drawable circle = UiUtils.drawCircle(trk.getColor(), (int) (res.getDimension(R.dimen.icon_size)), res);
|
||||
final int circleSize = (int) (res.getDimension(R.dimen.circle_size) + .5);
|
||||
// colors could be different, so dont use cache
|
||||
final Drawable circle = UiUtils.drawCircle(trk.getColor(), circleSize, res);
|
||||
icon.setImageDrawable(circle);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,13 @@ import android.graphics.Bitmap;
|
|||
|
||||
public class Icon
|
||||
{
|
||||
private String mName;
|
||||
private String mType;
|
||||
private Bitmap mIcon;
|
||||
private final String mName;
|
||||
private final String mType;
|
||||
|
||||
public Icon(String Name, String type, Bitmap Icon)
|
||||
{
|
||||
super();
|
||||
this.mName = Name;
|
||||
this.mIcon = Icon;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
|
@ -21,11 +19,6 @@ public class Icon
|
|||
return mType;
|
||||
}
|
||||
|
||||
public Bitmap getIcon()
|
||||
{
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
|
|
Loading…
Add table
Reference in a new issue