forked from organicmaps/organicmaps
[yopme] Refactoring, new API integration
This commit is contained in:
parent
4a33b7b377
commit
c45d59e4da
8 changed files with 260 additions and 298 deletions
|
@ -28,7 +28,8 @@
|
|||
<activity
|
||||
android:name="com.mapswithme.yopme.YopmeFrontActivity"
|
||||
android:configChanges="keyboardHidden|screenSize|orientation"
|
||||
android:label="@string/app_name" >
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop" >
|
||||
<intent-filter>
|
||||
<action
|
||||
android:name="android.intent.action.MAIN" />
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
android:id="@+id/modePoi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/poi" />
|
||||
|
||||
<RadioButton
|
||||
|
@ -55,7 +56,6 @@
|
|||
android:layout_below="@id/selectPoi"
|
||||
android:layout_marginTop="@dimen/dimen_4x"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="Белкалий"
|
||||
android:textSize="@dimen/mid_text" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -3,60 +3,115 @@ package com.mapswithme.yopme;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import com.mapswithme.yopme.bs.BackscreenBase;
|
||||
import com.mapswithme.yopme.bs.MyLocationBackscreen;
|
||||
import com.mapswithme.yopme.bs.PoiLocationBackscreen;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.api.MWMPoint;
|
||||
import com.mapswithme.yopme.map.MapData;
|
||||
import com.mapswithme.yopme.map.MapDataProvider;
|
||||
import com.mapswithme.yopme.map.MockMapDataProvider;
|
||||
import com.yotadevices.sdk.BSActivity;
|
||||
import com.yotadevices.sdk.BSMotionEvent;
|
||||
import com.yotadevices.sdk.BSDrawer.Waveform;
|
||||
import com.yotadevices.sdk.Constants.Gestures;
|
||||
|
||||
public class BackscreenActivity extends BSActivity
|
||||
{
|
||||
private BackscreenBase mBackscreenView;
|
||||
|
||||
public final static String EXTRA_MODE = "com.mapswithme.yopme.mode";
|
||||
public final static String EXTRA_POINT = "com.mapswithme.yopme.point";
|
||||
public final static String EXTRA_ZOOM = "com.mapswithme.yopme.zoom";
|
||||
public final static String EXTRA_LOCATION = "com.mapswithme.yopme.location";
|
||||
|
||||
private final static String TAG = "YOPME";
|
||||
|
||||
public enum Mode
|
||||
{
|
||||
NONE,
|
||||
LOCATION,
|
||||
POI,
|
||||
}
|
||||
|
||||
private CharSequence mMessage;
|
||||
private Bitmap mBitmap;
|
||||
|
||||
private MWMPoint mPoint;
|
||||
private Mode mMode;
|
||||
private double mZoomLevel = MapDataProvider.ZOOM_DEFAULT;
|
||||
private Location mLocation;
|
||||
|
||||
protected View mView;
|
||||
protected ImageView mMapView;
|
||||
protected TextView mPoiText;
|
||||
protected TextView mWaitMessage;
|
||||
protected View mWaitScreen;
|
||||
|
||||
protected MapDataProvider mMapDataProvider;
|
||||
|
||||
@Override
|
||||
protected void onBSCreate()
|
||||
{
|
||||
super.onBSCreate();
|
||||
restore();
|
||||
mBackscreenView.onCreate();
|
||||
|
||||
mMapDataProvider = new MockMapDataProvider(this);
|
||||
setUpView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBSResume()
|
||||
{
|
||||
super.onBSResume();
|
||||
mBackscreenView.onResume();
|
||||
|
||||
updateData();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void restore()
|
||||
@Override
|
||||
protected void onBSRestoreInstanceState(Bundle savedInstanceState)
|
||||
{
|
||||
final State state = State.read(this);
|
||||
if (state != null)
|
||||
{
|
||||
if (Mode.LOCATION == state.getMode())
|
||||
mBackscreenView = new MyLocationBackscreen(this, state);
|
||||
else if (Mode.POI == state.getMode())
|
||||
mBackscreenView = new PoiLocationBackscreen(this, state);
|
||||
}
|
||||
// TODO: what to do with null?
|
||||
super.onBSRestoreInstanceState(savedInstanceState);
|
||||
|
||||
if (savedInstanceState == null)
|
||||
return;
|
||||
|
||||
mPoint = (MWMPoint) savedInstanceState.getSerializable(EXTRA_POINT);
|
||||
mMode = (Mode) savedInstanceState.getSerializable(EXTRA_MODE);
|
||||
mLocation = (Location) savedInstanceState.getParcelable(EXTRA_LOCATION);
|
||||
mZoomLevel = savedInstanceState.getDouble(EXTRA_ZOOM);
|
||||
Log.d(TAG, "State restored.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBSSaveInstanceState(Bundle outState)
|
||||
{
|
||||
super.onBSSaveInstanceState(outState);
|
||||
|
||||
outState.putSerializable(EXTRA_POINT, mPoint);
|
||||
outState.putSerializable(EXTRA_MODE, mMode);
|
||||
outState.putParcelable(EXTRA_LOCATION, mLocation);
|
||||
outState.putDouble(EXTRA_ZOOM, mZoomLevel);
|
||||
Log.d(TAG, "State saved.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBSTouchEvent(BSMotionEvent motionEvent)
|
||||
{
|
||||
super.onBSTouchEvent(motionEvent);
|
||||
mBackscreenView.onMotionEvent(motionEvent);
|
||||
final Gestures action = motionEvent.getBSAction();
|
||||
|
||||
if (action == Gestures.GESTURES_BS_SINGLE_TAP)
|
||||
requestLocationUpdate();
|
||||
else if (action == Gestures.GESTURES_BS_LR)
|
||||
zoomIn();
|
||||
else if (action == Gestures.GESTURES_BS_RL)
|
||||
zoomOut();
|
||||
|
||||
updateData();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,19 +119,117 @@ public class BackscreenActivity extends BSActivity
|
|||
{
|
||||
super.onHandleIntent(intent);
|
||||
|
||||
if (intent.hasExtra(EXTRA_MODE))
|
||||
if (intent.hasExtra(LocationManager.KEY_LOCATION_CHANGED))
|
||||
onLocationUpdate((Location) intent.getParcelableExtra(LocationManager.KEY_LOCATION_CHANGED));
|
||||
else if (intent.hasExtra(EXTRA_MODE))
|
||||
{
|
||||
restore();
|
||||
mBackscreenView.invalidate();
|
||||
mMode = (Mode) intent.getSerializableExtra(EXTRA_MODE);
|
||||
mPoint = (MWMPoint) intent.getSerializableExtra(EXTRA_POINT);
|
||||
|
||||
updateData();
|
||||
invalidate();
|
||||
|
||||
if (mMode == Mode.LOCATION)
|
||||
requestLocationUpdate();
|
||||
}
|
||||
else if (intent.hasExtra(LocationManager.KEY_LOCATION_CHANGED))
|
||||
mBackscreenView.onLocationChanged((Location)intent.getParcelableExtra(LocationManager.KEY_LOCATION_CHANGED));
|
||||
}
|
||||
|
||||
public static void startInMode(Context context, Mode mode)
|
||||
public void setUpView()
|
||||
{
|
||||
mView = View.inflate(this, R.layout.yota_backscreen, null);
|
||||
|
||||
mMapView = (ImageView) mView.findViewById(R.id.map);
|
||||
mPoiText = (TextView) mView.findViewById(R.id.poiText);
|
||||
mWaitMessage = (TextView) mView.findViewById(R.id.waitMsg);
|
||||
mWaitScreen = mView.findViewById(R.id.waitScreen);
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
draw();
|
||||
}
|
||||
|
||||
private void zoomIn()
|
||||
{
|
||||
if (mZoomLevel < MapDataProvider.MAX_ZOOM)
|
||||
++mZoomLevel;
|
||||
}
|
||||
|
||||
private void zoomOut()
|
||||
{
|
||||
if (mZoomLevel > MapDataProvider.MIN_ZOOM)
|
||||
--mZoomLevel;
|
||||
}
|
||||
|
||||
protected void draw()
|
||||
{
|
||||
if (mView != null)
|
||||
getBSDrawer().drawBitmap(mView, Waveform.WAVEFORM_GC_FULL);
|
||||
}
|
||||
|
||||
private void requestLocationUpdate()
|
||||
{
|
||||
final LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER))
|
||||
lm.requestSingleUpdate(LocationManager.GPS_PROVIDER, BackscreenActivity.getLocationPendingIntent(this));
|
||||
else if (lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
|
||||
lm.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, BackscreenActivity.getLocationPendingIntent(this));
|
||||
else
|
||||
throw new IllegalStateException("No providers found.");
|
||||
|
||||
showWaitMessage("Waiting for location ...");
|
||||
}
|
||||
|
||||
private void onLocationUpdate(Location location)
|
||||
{
|
||||
hideWaitMessage();
|
||||
mLocation = location;
|
||||
|
||||
updateData();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void showWaitMessage(CharSequence msg)
|
||||
{
|
||||
mWaitMessage.setText(msg);
|
||||
mWaitScreen.setVisibility(View.VISIBLE);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void hideWaitMessage()
|
||||
{
|
||||
mWaitScreen.setVisibility(View.GONE);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void updateData()
|
||||
{
|
||||
MapData data = null;
|
||||
if (mMode == Mode.LOCATION)
|
||||
{
|
||||
if (mLocation == null)
|
||||
return;
|
||||
data = mMapDataProvider.getMyPositionData(mLocation.getLatitude(), mLocation.getLongitude(), mZoomLevel);
|
||||
}
|
||||
else if (mMode == Mode.POI)
|
||||
data = mMapDataProvider.getPOIData(mPoint, mZoomLevel);
|
||||
|
||||
mBitmap = data.getBitmap();
|
||||
mMessage = data.getPoint().getName();
|
||||
|
||||
mMapView.setImageBitmap(mBitmap);
|
||||
mPoiText.setText(mMessage);
|
||||
}
|
||||
|
||||
public static void startInMode(Context context, Mode mode, MWMPoint point)
|
||||
{
|
||||
final Intent i = new Intent(context, BackscreenActivity.class)
|
||||
.putExtra(EXTRA_MODE, mode);
|
||||
.putExtra(EXTRA_MODE, mode)
|
||||
.putExtra(EXTRA_POINT, point);
|
||||
|
||||
context.startService(i);
|
||||
}
|
||||
|
||||
|
@ -86,5 +239,4 @@ public class BackscreenActivity extends BSActivity
|
|||
final PendingIntent pi = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
return pi;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
package com.mapswithme.yopme;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.mapswithme.maps.api.MWMPoint;
|
||||
import com.mapswithme.yopme.BackscreenActivity.Mode;
|
||||
import com.mapswithme.yopme.util.Utils;
|
||||
|
||||
public class State implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String FILE_NAME = "state.st";
|
||||
|
||||
// state
|
||||
Mode mMode;
|
||||
MWMPoint mPoint;
|
||||
Bitmap mBackscreenBitmap;
|
||||
|
||||
public State(Mode mode, MWMPoint point, Bitmap backscreenBitmap)
|
||||
{
|
||||
mMode = mode;
|
||||
mPoint = point;
|
||||
mBackscreenBitmap = backscreenBitmap;
|
||||
}
|
||||
|
||||
public State()
|
||||
{
|
||||
mMode = Mode.NONE;
|
||||
mPoint = null;
|
||||
mBackscreenBitmap = null;
|
||||
}
|
||||
|
||||
public boolean hasPoint()
|
||||
{
|
||||
return mPoint != null;
|
||||
}
|
||||
|
||||
public boolean hasBitmap()
|
||||
{
|
||||
return mBackscreenBitmap != null;
|
||||
}
|
||||
|
||||
public Bitmap getBitmap()
|
||||
{
|
||||
return mBackscreenBitmap;
|
||||
}
|
||||
|
||||
public Mode getMode()
|
||||
{
|
||||
return mMode;
|
||||
}
|
||||
|
||||
public MWMPoint getPoint()
|
||||
{
|
||||
return mPoint;
|
||||
}
|
||||
|
||||
public void setPoint(MWMPoint point)
|
||||
{
|
||||
mPoint = point;
|
||||
}
|
||||
|
||||
public void setBitmap(Bitmap bitmap)
|
||||
{
|
||||
mBackscreenBitmap = bitmap;
|
||||
}
|
||||
|
||||
public void setMode(Mode mode)
|
||||
{
|
||||
mMode = mode;
|
||||
}
|
||||
|
||||
public synchronized static State read(Context context)
|
||||
{
|
||||
State state = null;
|
||||
Closeable closeable = null;
|
||||
try
|
||||
{
|
||||
final FileInputStream fis = context.openFileInput(FILE_NAME);
|
||||
final ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
closeable = ois;
|
||||
|
||||
state = (State) ois.readObject();
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Utils.close(closeable);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public synchronized static void write(Context context, State state)
|
||||
{
|
||||
Closeable closeable = null;
|
||||
try
|
||||
{
|
||||
final FileOutputStream fos = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
closeable = oos;
|
||||
|
||||
oos.writeObject(state);
|
||||
|
||||
oos.close();
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Utils.close(closeable);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
package com.mapswithme.yopme;
|
||||
|
||||
import com.mapswithme.maps.api.MWMPoint;
|
||||
import com.mapswithme.maps.api.MWMResponse;
|
||||
import com.mapswithme.maps.api.MapsWithMeApi;
|
||||
import com.mapswithme.yopme.BackscreenActivity.Mode;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -20,7 +25,19 @@ public class YopmeFrontActivity extends Activity
|
|||
private Button mSelectPoi;
|
||||
private TextView mPoiText;
|
||||
|
||||
private State mState = new State();
|
||||
private Mode mMode;
|
||||
private final static String KEY_MODE = "key.mode";
|
||||
private MWMPoint mPoint;
|
||||
private final static String KEY_POINT = "key.point";
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState)
|
||||
{
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putSerializable(KEY_MODE, mMode);
|
||||
outState.putSerializable(KEY_POINT, mPoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
|
@ -29,31 +46,40 @@ public class YopmeFrontActivity extends Activity
|
|||
setContentView(R.layout.activity_yopme_main);
|
||||
|
||||
setUpView();
|
||||
|
||||
//restore
|
||||
if (savedInstanceState != null)
|
||||
{
|
||||
mMode = (Mode) savedInstanceState.getSerializable(KEY_MODE);
|
||||
mPoint = (MWMPoint) savedInstanceState.getSerializable(KEY_POINT);
|
||||
|
||||
if (Mode.LOCATION == mMode)
|
||||
setLocationView();
|
||||
else if (Mode.POI == mMode)
|
||||
{
|
||||
setPoiView();
|
||||
mPoiText.setText(mPoint.getName());
|
||||
}
|
||||
}
|
||||
|
||||
setUpListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
protected void onNewIntent(Intent intent)
|
||||
{
|
||||
super.onResume();
|
||||
restoreFromState();
|
||||
}
|
||||
super.onNewIntent(intent);
|
||||
|
||||
private void saveState()
|
||||
{
|
||||
State.write(this, mState);
|
||||
}
|
||||
|
||||
private void restoreFromState()
|
||||
{
|
||||
mModeGroup.check(-1);
|
||||
final State st = State.read(this);
|
||||
if (st != null)
|
||||
if (intent.hasExtra(EXTRA_PICK) && intent.getBooleanExtra(EXTRA_PICK, false))
|
||||
{
|
||||
mState = st;
|
||||
if (st.mMode == Mode.LOCATION)
|
||||
mModeGroup.check(R.id.modeLocation);
|
||||
else if (st.mMode == Mode.POI)
|
||||
mModeGroup.check(R.id.modePoi);
|
||||
final MWMResponse response = MWMResponse.extractFromIntent(this, intent);
|
||||
if (response.hasPoint())
|
||||
{
|
||||
mPoint = response.getPoint();
|
||||
mPoiText.setText(mPoint.getName());
|
||||
BackscreenActivity.startInMode(this, Mode.POI, mPoint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +88,10 @@ public class YopmeFrontActivity extends Activity
|
|||
mModeGroup = (RadioGroup) findViewById(R.id.mode);
|
||||
mSelectPoi = (Button) findViewById(R.id.selectPoi);
|
||||
mPoiText = (TextView) findViewById(R.id.poi);
|
||||
}
|
||||
|
||||
private void setUpListeners()
|
||||
{
|
||||
mModeGroup.setOnCheckedChangeListener(this);
|
||||
mSelectPoi.setOnClickListener(this);
|
||||
}
|
||||
|
@ -77,40 +106,40 @@ public class YopmeFrontActivity extends Activity
|
|||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
//TODO add mapswithme invocation
|
||||
MapsWithMeApi.pickPoint(this, "Pick point", getPickPointPendingIntent());
|
||||
}
|
||||
|
||||
private final static String EXTRA_PICK = ".pick_point";
|
||||
private PendingIntent getPickPointPendingIntent()
|
||||
{
|
||||
final Intent i = new Intent(this, YopmeFrontActivity.class);
|
||||
i.putExtra(EXTRA_PICK, true);
|
||||
return PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId)
|
||||
{
|
||||
|
||||
if (checkedId == R.id.modeLocation)
|
||||
{
|
||||
BackscreenActivity.startInMode(getApplicationContext(), Mode.LOCATION);
|
||||
mState.setMode(Mode.LOCATION);
|
||||
mPoiText.setVisibility(View.GONE);
|
||||
//TODO: get location name
|
||||
|
||||
mSelectPoi.setEnabled(false);
|
||||
saveState();
|
||||
BackscreenActivity.startInMode(getApplicationContext(), Mode.LOCATION, null);
|
||||
setLocationView();
|
||||
}
|
||||
else if (checkedId == R.id.modePoi)
|
||||
{
|
||||
if (mState.hasPoint())
|
||||
{
|
||||
BackscreenActivity.startInMode(getApplicationContext(), Mode.POI);
|
||||
mPoiText.setText(mState.getPoint().getName());
|
||||
mPoiText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mState.setMode(Mode.POI);
|
||||
mSelectPoi.setEnabled(true);
|
||||
saveState();
|
||||
}
|
||||
else
|
||||
{
|
||||
mPoiText.setVisibility(View.VISIBLE);
|
||||
mPoiText.setText("Please select mode");
|
||||
mSelectPoi.setEnabled(false);
|
||||
}
|
||||
setPoiView();
|
||||
}
|
||||
|
||||
private void setPoiView()
|
||||
{
|
||||
mPoiText.setVisibility(View.VISIBLE);
|
||||
mPoiText.setText(null);
|
||||
mSelectPoi.setEnabled(true);
|
||||
}
|
||||
|
||||
private void setLocationView()
|
||||
{
|
||||
mPoiText.setVisibility(View.GONE);
|
||||
mPoiText.setText(null);
|
||||
mSelectPoi.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package com.mapswithme.yopme.bs;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mapswithme.yopme.State;
|
||||
import com.mapswithme.yopme.map.MapData;
|
||||
import com.mapswithme.yopme.map.MapDataProvider;
|
||||
import com.yotadevices.sdk.BSActivity;
|
||||
import com.yotadevices.sdk.BSMotionEvent;
|
||||
|
||||
public class MyLocationBackscreen extends BackscreenBase
|
||||
{
|
||||
|
||||
public MyLocationBackscreen(BSActivity bsActivity, State state)
|
||||
{
|
||||
super(bsActivity, state);
|
||||
|
||||
mock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(BSMotionEvent motionEvent)
|
||||
{
|
||||
super.onMotionEvent(motionEvent);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location)
|
||||
{
|
||||
super.onLocationChanged(location);
|
||||
mock();
|
||||
}
|
||||
|
||||
private void mock()
|
||||
{
|
||||
final Location location = new Location("");
|
||||
final MapData data = mMapDataProvider
|
||||
.getMyPositionData(location.getLatitude(), location.getLongitude(), MapDataProvider.ZOOM_DEFAULT);
|
||||
|
||||
mState = new State(mState.getMode(), data.getPoint(), data.getBitmap());
|
||||
|
||||
State.write(mBsActivity, mState);
|
||||
updateView(mState);
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package com.mapswithme.yopme.bs;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mapswithme.maps.api.MWMPoint;
|
||||
import com.mapswithme.yopme.State;
|
||||
import com.mapswithme.yopme.map.MapData;
|
||||
import com.mapswithme.yopme.map.MapDataProvider;
|
||||
import com.yotadevices.sdk.BSActivity;
|
||||
import com.yotadevices.sdk.BSMotionEvent;
|
||||
|
||||
public class PoiLocationBackscreen extends BackscreenBase
|
||||
{
|
||||
public PoiLocationBackscreen(BSActivity bsActivity, State state)
|
||||
{
|
||||
super(bsActivity, state);
|
||||
|
||||
mock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(BSMotionEvent motionEvent)
|
||||
{
|
||||
super.onMotionEvent(motionEvent);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location)
|
||||
{
|
||||
super.onLocationChanged(location);
|
||||
// TODO: get location name from MWM
|
||||
mock();
|
||||
}
|
||||
|
||||
private void mock()
|
||||
{
|
||||
final Location location = new Location("");
|
||||
final MapData data = mMapDataProvider.getPOIData(
|
||||
new MWMPoint(location.getLatitude(), location.getLongitude(), ""), MapDataProvider.ZOOM_DEFAULT);
|
||||
mState = new State(mState.getMode(), data.getPoint(), data.getBitmap());
|
||||
updateView(mState);
|
||||
State.write(mBsActivity, mState);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,15 +18,14 @@ public class MockMapDataProvider implements MapDataProvider
|
|||
@Override
|
||||
public MapData getMyPositionData(double lat, double lon, double zoom)
|
||||
{
|
||||
final MWMPoint point = new MWMPoint(0, 0, "Minsk");
|
||||
final MWMPoint point = new MWMPoint(0, 0, "You are here!");
|
||||
return new MapData(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.minsk_ink), point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapData getPOIData(MWMPoint poi, double zoom)
|
||||
{
|
||||
final MWMPoint point = new MWMPoint(0, 0, "Moskow");
|
||||
return new MapData(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.msk_ink), point);
|
||||
return new MapData(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.msk_ink), poi);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue