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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2013-02-07 15:56:10 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:50:46 +0300
commit7c8634e74fc1f94b0a730d14ddb6ca6c603e4da7 (patch)
tree930304b9585011e74da72f7b9ddcb8de2b649aca /android
parentfb7491a7d79411236484c42ef89c0b41a5fad826 (diff)
[android] Compilation fixes.
Diffstat (limited to 'android')
-rw-r--r--android/jni/com/mapswithme/maps/SearchActivity.cpp4
-rw-r--r--android/src/com/mapswithme/maps/SearchActivity.java18
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java24
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java69
4 files changed, 52 insertions, 63 deletions
diff --git a/android/jni/com/mapswithme/maps/SearchActivity.cpp b/android/jni/com/mapswithme/maps/SearchActivity.cpp
index bba43e67bf..69c85588e8 100644
--- a/android/jni/com/mapswithme/maps/SearchActivity.cpp
+++ b/android/jni/com/mapswithme/maps/SearchActivity.cpp
@@ -221,7 +221,7 @@ Java_com_mapswithme_maps_SearchActivity_nativeGetResult(
{
jmethodID methodID = env->GetMethodID(
klass, "<init>",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DDD)V");
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V");
ASSERT ( methodID, () );
string distance;
@@ -244,8 +244,6 @@ Java_com_mapswithme_maps_SearchActivity_nativeGetResult(
jni::ToJavaString(env, res->GetFeatureType()),
jni::ToJavaString(env, res->GetRegionFlag()),
jni::ToJavaString(env, distance.c_str()),
- static_cast<jdouble>(mer.x),
- static_cast<jdouble>(mer.y),
static_cast<jdouble>(azimut));
}
else
diff --git a/android/src/com/mapswithme/maps/SearchActivity.java b/android/src/com/mapswithme/maps/SearchActivity.java
index b5081f229e..5bb5c93e13 100644
--- a/android/src/com/mapswithme/maps/SearchActivity.java
+++ b/android/src/com/mapswithme/maps/SearchActivity.java
@@ -6,8 +6,6 @@ import android.app.ListActivity;
import android.content.Context;
import android.content.res.Resources;
import android.location.Location;
-import android.content.Intent;
-
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -25,9 +23,6 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
-import com.mapswithme.maps.bookmarks.data.AddressInfo;
-import com.mapswithme.maps.bookmarks.data.Bookmark;
-import com.mapswithme.maps.bookmarks.data.ParcelablePointD;
import com.mapswithme.maps.location.LocationService;
@@ -37,7 +32,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
public static final String SEARCH_RESULT = "search_result";
private static class SearchAdapter extends BaseAdapter
- {;
+ {
private final SearchActivity m_context;
private final LayoutInflater m_inflater;
@@ -186,7 +181,6 @@ public class SearchActivity extends ListActivity implements LocationService.List
/// Created from native code.
public static class SearchResult
{
- public ParcelablePointD mLocation;
public String m_name;
public String m_country;
public String m_amenity;
@@ -211,7 +205,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
// Called from native code
@SuppressWarnings("unused")
public SearchResult(String name, String country, String amenity,
- String flag, String distance, double lat, double lon, double azimut)
+ String flag, String distance, double azimut)
{
m_name = name;
m_country = country;
@@ -221,16 +215,8 @@ public class SearchActivity extends ListActivity implements LocationService.List
m_distance = distance;
m_azimut = azimut;
- mLocation = new ParcelablePointD(lat, lon);
-
m_type = 1;
}
-
- //Native code return location in mercator coordinates, we need screen coordinates
- public AddressInfo getAddressInfo()
- {
- return new AddressInfo(m_name, m_amenity, Bookmark.GtoP(mLocation));
- }
}
private String getCategoryName(String strID)
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
index bb91ff5112..b5a17f7c2e 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
@@ -1,7 +1,6 @@
package com.mapswithme.maps.bookmarks;
import android.content.Intent;
-import android.graphics.Point;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -14,17 +13,16 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
-import android.widget.EditText;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.EditText;
import com.mapswithme.maps.MWMActivity;
import com.mapswithme.maps.MWMApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.BookmarkListAdapter.DataChangedListener;
-import com.mapswithme.maps.bookmarks.data.Bookmark;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.ParcelablePoint;
-import com.mapswithme.maps.location.LocationService;
+
public class BookmarkListActivity extends AbstractBookmarkListActivity
{
@@ -33,10 +31,8 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
private EditText mSetName;
private CheckBox mIsVisible;
private BookmarkCategory mEditedSet;
- private Bookmark mBookmark;
private int mSelectedPosition;
private BookmarkListAdapter mPinAdapter;
- private LocationService mLocation;
private boolean mEditContent;
@Override
@@ -49,8 +45,6 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
mEditedSet = mManager.getCategoryById(setIndex);
setTitle(mEditedSet.getName());
- mLocation = ((MWMApplication) getApplication()).getLocationService();
-
if (mEditedSet != null)
createListAdapter();
@@ -71,7 +65,9 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
private void createListAdapter()
{
- setListAdapter(mPinAdapter = new BookmarkListAdapter(BookmarkListActivity.this, mEditedSet, new DataChangedListener()
+ setListAdapter(mPinAdapter = new BookmarkListAdapter(this,
+ ((MWMApplication) getApplication()).getLocationService(),
+ mEditedSet, new DataChangedListener()
{
@Override
public void onDataChanged(int vis)
@@ -79,7 +75,8 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
findViewById(R.id.bookmark_usage_hint).setVisibility(vis);
}
}));
- mLocation.startUpdate(mPinAdapter);
+
+ mPinAdapter.startLocationUpdate();
}
private void setUpViews()
@@ -165,6 +162,7 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
protected void onStart()
{
super.onStart();
+
if (mPinAdapter != null)
mPinAdapter.notifyDataSetChanged();
}
@@ -173,7 +171,8 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
protected void onPause()
{
if (mPinAdapter != null)
- mLocation.stopUpdate(mPinAdapter);
+ mPinAdapter.stopLocationUpdate();
+
super.onPause();
}
@@ -181,7 +180,8 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
protected void onResume()
{
super.onResume();
+
if (mPinAdapter != null)
- mLocation.startUpdate(mPinAdapter);
+ mPinAdapter.startLocationUpdate();
}
}
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java
index 9ef972dae4..9524223f4e 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkListAdapter.java
@@ -1,7 +1,7 @@
package com.mapswithme.maps.bookmarks;
import android.app.Activity;
-import android.util.Log;
+import android.location.Location;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -14,42 +14,55 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.Bookmark;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.DistanceAndAthimuth;
-import com.mapswithme.maps.bookmarks.data.ParcelablePointD;
import com.mapswithme.maps.location.LocationService;
+
public class BookmarkListAdapter extends BaseAdapter implements LocationService.Listener
{
- Activity mContext;
- BookmarkCategory mCategory;
+ private Activity mContext;
+ private BookmarkCategory mCategory;
private double mNorth = -1;
- private boolean mHasPosition;
- private ParcelablePointD mCurrentPosition;
+ private LocationService mLocation;
private DataChangedListener mDataChangedListener;
- public BookmarkListAdapter(Activity context, BookmarkCategory cat, DataChangedListener dcl)
+ public BookmarkListAdapter(Activity context, LocationService location,
+ BookmarkCategory cat, DataChangedListener dcl)
{
mContext = context;
+ mLocation = location;
mCategory = cat;
mDataChangedListener = dcl;
}
+ public void startLocationUpdate()
+ {
+ mLocation.startUpdate(this);
+ }
+
+ public void stopLocationUpdate()
+ {
+ mLocation.stopUpdate(this);
+ }
+
+
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
convertView = LayoutInflater.from(mContext).inflate(R.layout.pin_item, null);
- convertView.setTag(new PinHolder((ArrowImage) convertView.findViewById(R.id.pi_arrow), (ImageView) convertView
- .findViewById(R.id.pi_pin_color), (TextView) convertView.findViewById(R.id.pi_name), (TextView) convertView
- .findViewById(R.id.pi_distance)));
+ convertView.setTag(new PinHolder(convertView));
}
+
Bookmark item = mCategory.getBookmark(position);
PinHolder holder = (PinHolder) convertView.getTag();
holder.name.setText(item.getName());
holder.icon.setImageBitmap(item.getIcon().getIcon());
- if (mHasPosition)
+
+ final Location loc = mLocation.getLastKnown();
+ if (mNorth != -1.0 && loc != null)
{
- DistanceAndAthimuth daa = item.getDistanceAndAthimuth(mCurrentPosition.x, mCurrentPosition.y, mNorth);
+ DistanceAndAthimuth daa = item.getDistanceAndAthimuth(loc.getLatitude(), loc.getLongitude(), mNorth);
holder.distance.setText(daa.getDistance());
holder.arrow.setAzimut(daa.getAthimuth());
}
@@ -58,6 +71,7 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
holder.distance.setText("");
holder.arrow.setImageDrawable(null);
}
+
//Log.d("lat lot", item.getLat() + " " + item.getLon());
return convertView;
}
@@ -66,6 +80,7 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
public void notifyDataSetChanged()
{
super.notifyDataSetChanged();
+
if (mDataChangedListener != null)
{
mDataChangedListener.onDataChanged(isEmpty() ? View.VISIBLE : View.GONE);
@@ -91,27 +106,21 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
}
@Override
- public void onLocationUpdated(long time, double lat, double lon,
- float accuracy)
+ public void onLocationUpdated(long time, double lat, double lon, float accuracy)
{
- mCurrentPosition = new ParcelablePointD(lat, lon);
- mHasPosition = true;
notifyDataSetChanged();
}
@Override
public void onCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy)
{
- @SuppressWarnings("deprecation")
- final int orientation = mContext.getWindowManager().getDefaultDisplay().getOrientation();
- final double correction = LocationService.getAngleCorrection(orientation);
-
- final double north = LocationService.correctAngle(trueNorth, correction);
+ double north[] = { trueNorth };
+ mLocation.correctCompassAngles(mContext.getWindowManager().getDefaultDisplay(), north);
// if difference is more than 1 degree
- if (mNorth == -1 || Math.abs(mNorth - north) > 0.02)
+ if (mNorth == -1 || Math.abs(mNorth - north[0]) > 0.02)
{
- mNorth = north;
+ mNorth = north[0];
//Log.d(TAG, "Compass updated, north = " + m_north);
notifyDataSetChanged();
@@ -121,9 +130,6 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
@Override
public void onLocationError(int errorCode)
{
- /// @TODO handle it in location service.
- mHasPosition = false;
- notifyDataSetChanged();
}
private static class PinHolder
@@ -133,13 +139,12 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
TextView name;
TextView distance;
- public PinHolder(ArrowImage arrow, ImageView icon, TextView name, TextView distance)
+ public PinHolder(View convertView)
{
- super();
- this.arrow = arrow;
- this.icon = icon;
- this.name = name;
- this.distance = distance;
+ arrow = (ArrowImage) convertView.findViewById(R.id.pi_arrow);
+ icon = (ImageView) convertView.findViewById(R.id.pi_pin_color);
+ name = (TextView) convertView.findViewById(R.id.pi_name);
+ distance = (TextView) convertView.findViewById(R.id.pi_distance);
}
}