forked from organicmaps/organicmaps
[android] [bookmarks] Process distance and direction for the list of bookmarks separately (according to available sensors).
This commit is contained in:
parent
39a9c09e5a
commit
739a92e67b
3 changed files with 31 additions and 9 deletions
|
@ -34,6 +34,8 @@ public class ArrowImage extends ImageView
|
|||
|
||||
public void setFlag(Resources res, String packageName, String flag)
|
||||
{
|
||||
setVisibility(VISIBLE);
|
||||
|
||||
m_drawArrow = false;
|
||||
|
||||
// The aapt can't process resources with name "do". Hack with renaming.
|
||||
|
@ -42,17 +44,38 @@ public class ArrowImage extends ImageView
|
|||
|
||||
final int id = res.getIdentifier(flag, "drawable", packageName);
|
||||
if (id > 0)
|
||||
{
|
||||
setImageDrawable(res.getDrawable(id));
|
||||
}
|
||||
else
|
||||
{
|
||||
setImageDrawable(null);
|
||||
|
||||
Log.e(TAG, "Failed to get resource id from: " + flag);
|
||||
}
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setAzimut(double azimut)
|
||||
{
|
||||
setVisibility(VISIBLE);
|
||||
|
||||
setImageDrawable(null);
|
||||
|
||||
m_drawArrow = true;
|
||||
m_angle = (float)(azimut / Math.PI * 180.0);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
setVisibility(INVISIBLE);
|
||||
|
||||
setImageDrawable(null);
|
||||
|
||||
m_drawArrow = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -308,18 +308,13 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
|
||||
if (r.m_type == 1)
|
||||
{
|
||||
holder.m_flag.setVisibility(View.VISIBLE);
|
||||
|
||||
if (r.m_flag != null && r.m_flag.length() > 0 && r.m_azimut < 0.0)
|
||||
holder.m_flag.setFlag(m_resource, m_packageName, r.m_flag);
|
||||
else
|
||||
holder.m_flag.setAzimut(r.m_azimut);
|
||||
|
||||
// force invalidate arrow image
|
||||
holder.m_flag.invalidate();
|
||||
}
|
||||
else
|
||||
holder.m_flag.setVisibility(View.INVISIBLE);
|
||||
holder.m_flag.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,16 +60,20 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
|
|||
holder.icon.setImageBitmap(item.getIcon().getIcon());
|
||||
|
||||
final Location loc = mLocation.getLastKnown();
|
||||
if (mNorth != -1.0 && loc != null)
|
||||
if (loc != null)
|
||||
{
|
||||
DistanceAndAthimuth daa = item.getDistanceAndAthimuth(loc.getLatitude(), loc.getLongitude(), mNorth);
|
||||
holder.distance.setText(daa.getDistance());
|
||||
holder.arrow.setAzimut(daa.getAthimuth());
|
||||
|
||||
if (daa.getAthimuth() >= 0.0)
|
||||
holder.arrow.setAzimut(daa.getAthimuth());
|
||||
else
|
||||
holder.arrow.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.distance.setText("");
|
||||
holder.arrow.setImageDrawable(null);
|
||||
holder.arrow.clear();
|
||||
}
|
||||
|
||||
//Log.d("lat lot", item.getLat() + " " + item.getLon());
|
||||
|
|
Loading…
Add table
Reference in a new issue