Replaced dynamic map with static on Dashboard
This commit is contained in:
parent
68ba8052c4
commit
7cf7db1b8c
2 changed files with 37 additions and 48 deletions
|
@ -39,14 +39,14 @@
|
|||
android:textSize="@dimen/dashProgressTextSize"/>
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
android:layout_width="fill_parent"
|
||||
<ImageView android:id="@+id/map_image"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dashMapHeight"
|
||||
android:layout_marginLeft="@dimen/dashMapMargin"
|
||||
android:layout_marginRight="@dimen/dashMapMargin"
|
||||
android:layout_marginBottom="@dimen/dashMapMargin"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.ImageView;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
||||
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
||||
|
@ -28,7 +30,6 @@ import android.widget.TextView;
|
|||
public class DashMapFragment extends DashBaseFragment implements IMapDownloaderCallback {
|
||||
|
||||
public static final String TAG = "DASH_MAP_FRAGMENT";
|
||||
private OsmandMapTileView osmandMapTileView;
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
@ -52,7 +53,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||
((TextView) view.findViewById(R.id.map_text)).setTypeface(typeface);
|
||||
((Button) view.findViewById(R.id.show_map)).setTypeface(typeface);
|
||||
setupMapView(view);
|
||||
|
||||
(view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -61,48 +62,40 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
|
||||
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setupMapView(View view){
|
||||
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) view.findViewById(R.id.MapView);
|
||||
surf.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
((ImageView) view.findViewById(R.id.map_image)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startMapActivity();
|
||||
}
|
||||
});
|
||||
osmandMapTileView = surf.getMapView();
|
||||
osmandMapTileView.getView().setVisibility(View.VISIBLE);
|
||||
osmandMapTileView.removeAllLayers();
|
||||
MapVectorLayer mapVectorLayer = new MapVectorLayer(null, true);
|
||||
MapTextLayer mapTextLayer = new MapTextLayer();
|
||||
mapTextLayer.setAlwaysVisible(true);
|
||||
// 5.95 all labels
|
||||
osmandMapTileView.addLayer(mapTextLayer, 5.95f);
|
||||
osmandMapTileView.addLayer(mapVectorLayer, 0.5f);
|
||||
osmandMapTileView.setMainLayer(mapVectorLayer);
|
||||
mapVectorLayer.setVisible(true);
|
||||
osmandMapTileView.setShowMapPosition(false);
|
||||
setMapImage(view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setMapImage(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
Bitmap image = getMyApplication().getResourceManager().getRenderer().getBitmap();
|
||||
ImageView map = (ImageView) view.findViewById(R.id.map_image);
|
||||
if (image != null){
|
||||
map.setImageBitmap(image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int zm = getMyApplication().getSettings().getLastKnownMapZoom();
|
||||
//Let us not change zoom here, it provides for a smoother transition between the map and the dashboard screens, and provides better recognition of the map fragment
|
||||
//zm = Math.max(zm - 3, 4);
|
||||
osmandMapTileView.setLatLon(lm.getLatitude(), lm.getLongitude());
|
||||
osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsMapDensity());
|
||||
osmandMapTileView.refreshMap(true);
|
||||
setMapImage(getView());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
view.findViewById(R.id.MapView).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.map_image).setVisibility(View.GONE);
|
||||
if(getMyApplication().isApplicationInitializing()) {
|
||||
getMyApplication().checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
||||
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
||||
|
@ -121,7 +114,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
MainMenuActivity dashboardActivity =((MainMenuActivity)getSherlockActivity());
|
||||
if (dashboardActivity != null){
|
||||
dashboardActivity.updateDownloads();
|
||||
view.findViewById(R.id.MapView).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.map_image).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,11 +123,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
if(request != null && !request.error && request.fileToSave != null){
|
||||
ResourceManager mgr = getMyApplication().getResourceManager();
|
||||
mgr.tileDownloaded(request);
|
||||
}
|
||||
if(request == null || !request.error){
|
||||
if(osmandMapTileView != null) {
|
||||
osmandMapTileView.tileDownloaded(request);
|
||||
}
|
||||
setMapImage(getView());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue