Add update dashboard method

This commit is contained in:
Victor Shcherb 2015-03-08 15:20:53 +01:00
parent 9882da1594
commit 7fb1bee03a
16 changed files with 161 additions and 186 deletions

View file

@ -1,8 +1,6 @@
package net.osmand.plus;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@ -11,22 +9,15 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import android.app.AlertDialog;
import android.content.Context;
public class FavouritesDbHelper {
@ -34,7 +25,6 @@ public class FavouritesDbHelper {
void updateFavourites();
}
private List<FavoritesUpdatedListener> favoritesUpdatedListeners = new ArrayList<FavoritesUpdatedListener>();
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(FavouritesDbHelper.class);
@ -93,20 +83,8 @@ public class FavouritesDbHelper {
}
private void favouritesUpdated(){
for (FavoritesUpdatedListener listener : favoritesUpdatedListeners){
listener.updateFavourites();
}
}
public void addFavoritesUpdatedListener(FavoritesUpdatedListener listener){
if (!favoritesUpdatedListeners.contains(listener)){
favoritesUpdatedListeners.add(listener);
}
}
public void removeFavoritesUpdatedListener(FavoritesUpdatedListener listener){
favoritesUpdatedListeners.remove(listener);
}
private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) {
boolean changed = false;

View file

@ -58,19 +58,13 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
}
@Override
public void onOpenUpdate() {
public void onOpenDash() {
if (plugin == null) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
}
setupNotes();
}
@Override
public void onPause() {
super.onPause();
}
public void setupNotes() {
View mainView = getView();
if (plugin == null){

View file

@ -29,7 +29,26 @@ public abstract class DashBaseFragment extends Fragment {
}
}
public void onOpenUpdate() {}
public abstract void onOpenDash() ;
public void onCloseDash() {
}
@Override
public final void onPause() {
// use on close
super.onPause();
onCloseDash();
}
@Override
public final void onResume() {
// use on open update
super.onResume();
if(dashboard != null && dashboard.isVisible()) {
onOpenDash();
}
}
public void onLocationCompassChanged(Location l, double compassValue) {

View file

@ -64,7 +64,7 @@ public class DashDownloadMapsFragment extends DashBaseFragment {
}
@Override
public void onOpenUpdate() {
public void onOpenDash() {
refreshData();
}

View file

@ -84,6 +84,6 @@ public class DashErrorFragment extends DashBaseFragment {
}
@Override
public void onOpenUpdate() {
public void onOpenDash() {
}
}

View file

@ -13,11 +13,11 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.content.Intent;
@ -33,8 +33,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
/**
* Created by Denis
* on 24.11.2014.
* Created by Denis on 24.11.2014.
*/
public class DashFavoritesFragment extends DashLocationFragment implements FavouritesDbHelper.FavoritesUpdatedListener {
public static final String TAG = "DASH_FAVORITES_FRAGMENT";
@ -63,38 +62,29 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
});
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onResume() {
super.onResume();
//This is used as origin for both Fav-list and direction arrows
public void onOpenDash() {
// This is used as origin for both Fav-list and direction arrows
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
loc = getMyApplication().getSettings().getLastKnownMapLocation();
} else {
loc = new LatLon(0f, 0f);
}
getMyApplication().getFavorites().addFavoritesUpdatedListener(this);
setupFavorites();
}
@Override
public void onPause() {
super.onPause();
getMyApplication().getFavorites().removeFavoritesUpdatedListener(this);
}
public void setupFavorites(){
public void setupFavorites() {
View mainView = getView();
final FavouritesDbHelper helper = getMyApplication().getFavorites();
points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
arrows.clear();
if (points.size() == 0){
if (points.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
@ -104,18 +94,18 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
Collections.sort(points, new Comparator<FavouritePoint>() {
@Override
public int compare(FavouritePoint point, FavouritePoint point2) {
//LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
loc.getLatitude(), loc.getLongitude()));
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(),
loc.getLatitude(), loc.getLongitude()));
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), loc.getLatitude(),
loc.getLongitude()));
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(), loc.getLatitude(),
loc.getLongitude()));
return (dist - dist2);
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
if (points.size() > 3){
while (points.size() != 3){
if (points.size() > 3) {
while (points.size() != 3) {
points.remove(3);
}
}
@ -132,27 +122,27 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
view.findViewById(R.id.group_image).setVisibility(View.GONE);
}
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(
getActivity(), point.getColor()));
((ImageView) view.findViewById(R.id.favourite_icon)).
setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), point.getColor()));
if(loc != null){
if (loc != null) {
direction.setVisibility(View.VISIBLE);
updateArrow(getActivity(), loc, new LatLon(point.getLatitude(), point.getLongitude()), direction,
10, R.drawable.ic_destination_arrow, heading);
updateArrow(getActivity(), loc, new LatLon(point.getLatitude(), point.getLongitude()), direction, 10,
R.drawable.ic_destination_arrow, heading);
}
arrows.add(direction);
name.setText(point.getName());
//LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
loc.getLatitude(), loc.getLongitude()));
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), loc.getLatitude(),
loc.getLongitude()));
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), point.getLatitude(), point.getLongitude(),
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), point.getLatitude(),
point.getLongitude(),
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()));
}
});
@ -161,8 +151,8 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), 15,
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true,
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(),
15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true,
point); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity());
}
@ -186,7 +176,7 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
@Override
public boolean updateCompassValue(float value) {
if (super.updateCompassValue(value)){
if (super.updateCompassValue(value)) {
updateArrows();
}
return true;

View file

@ -60,6 +60,13 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloaderC
protected void startMapActivity() {
MapActivity.launchMapActivityMoveToTop(getActivity());
}
@Override
public void onOpenDash() {
if (!getMyApplication().isApplicationInitializing()) {
updateMapImage();
}
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -112,15 +119,6 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloaderC
}
@Override
public void onResume() {
super.onResume();
if (!getMyApplication().isApplicationInitializing()) {
updateMapImage();
}
}
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

View file

@ -87,10 +87,9 @@ public class DashPluginsFragment extends DashBaseFragment {
return contentView;
}
@Override
public void onResume() {
super.onResume();
@Override
public void onOpenDash() {
View contentView = getView();
if (contentView == null) {
return;
@ -99,9 +98,9 @@ public class DashPluginsFragment extends DashBaseFragment {
for (int pluginIndex = 0; pluginIndex < plugins.size(); pluginIndex++) {
View pluginView = pluginsContainer.getChildAt(pluginIndex);
updatePluginState(pluginView, plugins.get(pluginIndex));
}
}
}
private void updatePluginState(View pluginView, OsmandPlugin plugin) {
CompoundButton enableDisableButton = (CompoundButton) pluginView.findViewById(R.id.plugin_enable_disable);
Button getButton = (Button) pluginView.findViewById(R.id.get_plugin);

View file

@ -32,8 +32,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
/**
* Created by Denis
* on 24.11.2014.
* Created by Denis on 24.11.2014.
*/
public class DashRecentsFragment extends DashLocationFragment {
public static final String TAG = "DASH_RECENTS_FRAGMENT";
@ -47,8 +46,8 @@ public class DashRecentsFragment extends DashLocationFragment {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((TextView) view.findViewById(R.id.fav_text)).setText(
Algorithms.capitalizeFirstLetterAndLowercase(getString(R.string.recents)));
((TextView) view.findViewById(R.id.fav_text)).setText(Algorithms
.capitalizeFirstLetterAndLowercase(getString(R.string.recents)));
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@ -56,9 +55,9 @@ public class DashRecentsFragment extends DashLocationFragment {
public void onClick(View view) {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
//search.putExtra(SearchActivity.SHOW_ONLY_ONE_TAB, true);
// search.putExtra(SearchActivity.SHOW_ONLY_ONE_TAB, true);
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.HISTORY_TAB_INDEX);
activity.startActivity(search);
@ -71,12 +70,10 @@ public class DashRecentsFragment extends DashLocationFragment {
}
return view;
}
@Override
public void onResume() {
super.onResume();
//This is used as origin for both Fav-list and direction arrows
public void onOpenDash() {
// This is used as origin for both Fav-list and direction arrows
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
loc = getMyApplication().getSettings().getLastKnownMapLocation();
} else {
@ -85,17 +82,13 @@ public class DashRecentsFragment extends DashLocationFragment {
setupRecents();
}
@Override
public void onPause() {
super.onPause();
}
public void setupRecents(){
public void setupRecents() {
View mainView = getView();
SearchHistoryHelper helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity().getApplicationContext());
SearchHistoryHelper helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity()
.getApplicationContext());
points = helper.getHistoryEntries();
arrows.clear();
if (points.size() == 0){
if (points.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
@ -104,28 +97,26 @@ public class DashRecentsFragment extends DashLocationFragment {
LinearLayout recents = (LinearLayout) mainView.findViewById(R.id.items);
recents.removeAllViews();
if (points.size() > 3){
if (points.size() > 3) {
points = points.subList(0, 3);
}
for (final HistoryEntry historyEntry : points) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.search_history_list_item, null, false);
SearchHistoryFragment.udpateHistoryItem(historyEntry, view,
loc, getActivity(), getMyApplication());
SearchHistoryFragment.udpateHistoryItem(historyEntry, view, loc, getActivity(), getMyApplication());
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), historyEntry.getLat(), historyEntry.getLon(),
historyEntry.getName());
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), historyEntry.getLat(),
historyEntry.getLon(), historyEntry.getName());
}
});
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getSettings().setMapLocationToShow(historyEntry.getLat(), historyEntry.getLon(), 15,
historyEntry.getName(), true,
historyEntry); //$NON-NLS-1$
getMyApplication().getSettings().setMapLocationToShow(historyEntry.getLat(), historyEntry.getLon(),
15, historyEntry.getName(), true, historyEntry); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
@ -140,14 +131,14 @@ public class DashRecentsFragment extends DashLocationFragment {
for (int i = 0; i < arrows.size(); i++) {
arrows.get(i).setVisibility(View.VISIBLE);
updateArrow(getActivity(), loc, new LatLon(points.get(i).getLat(), points.get(i).getLon()),
arrows.get(i), 10, R.drawable.ic_destination_arrow, heading);
updateArrow(getActivity(), loc, new LatLon(points.get(i).getLat(), points.get(i).getLon()), arrows.get(i),
10, R.drawable.ic_destination_arrow, heading);
}
}
@Override
public boolean updateCompassValue(float value) {
if (super.updateCompassValue(value)){
if (super.updateCompassValue(value)) {
updateArrows();
}
return true;

View file

@ -32,11 +32,6 @@ public class DashSearchFragment extends DashBaseFragment {
return view;
}
@Override
public void onResume() {
super.onResume();
}
protected void searchActivity(final Activity activity, final OsmAndAppCustomization appCustomization, int tab) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
@ -78,4 +73,9 @@ public class DashSearchFragment extends DashBaseFragment {
}
});
}
@Override
public void onOpenDash() {
}
}

View file

@ -5,26 +5,29 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import android.graphics.Typeface;
import android.widget.*;
import net.osmand.plus.R;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.helpers.FontCache;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.helpers.FontCache;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
/**
* Created by Denis
* on 21.11.2014.
* Created by Denis on 21.11.2014.
*/
public class DashUpdatesFragment extends DashBaseFragment {
@ -47,9 +50,10 @@ public class DashUpdatesFragment extends DashBaseFragment {
showAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization()
.getDownloadIndexActivity());
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.UPDATES_TAB);
//intent.putExtra(DownloadActivity.SINGLE_TAB, true);
// intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
@ -57,13 +61,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onResume() {
super.onResume();
public void onOpenDash() {
downloadQueue.clear();
if (BaseDownloadActivity.downloadListIndexThread != null) {
currentProgress = null;
@ -79,19 +77,20 @@ public class DashUpdatesFragment extends DashBaseFragment {
@Override
public int compare(IndexItem indexItem, IndexItem t1) {
DatabaseHelper helper = BaseDownloadActivity.downloadListIndexThread.getDbHelper();
return (int)(helper.getCount(t1.getBasename(), DatabaseHelper.DOWNLOAD_ENTRY) -
helper.getCount(indexItem.getBasename(), DatabaseHelper.DOWNLOAD_ENTRY));
return (int) (helper.getCount(t1.getBasename(), DatabaseHelper.DOWNLOAD_ENTRY) - helper.getCount(
indexItem.getBasename(), DatabaseHelper.DOWNLOAD_ENTRY));
}
});
View mainView = getView();
//it may be null because download index thread is async
// it may be null because download index thread is async
if (mainView == null) {
return;
}
progressBars.clear();
baseNames.clear();
downloadButtons.clear();
((TextView) mainView.findViewById(R.id.header)).setText(getString(R.string.map_update ,String.valueOf(list.size())));
((TextView) mainView.findViewById(R.id.header)).setText(getString(R.string.map_update,
String.valueOf(list.size())));
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
updates.removeAllViews();
@ -110,8 +109,10 @@ public class DashUpdatesFragment extends DashBaseFragment {
}
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_updates_item, null, false);
String name = item.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions());
String d = item.getDate(getMyApplication().getResourceManager().getDateFormat()) + ", " + item.getSizeDescription(getMyApplication());
String name = item.getVisibleName(getMyApplication(), getMyApplication().getResourceManager()
.getOsmandRegions());
String d = item.getDate(getMyApplication().getResourceManager().getDateFormat()) + ", "
+ item.getSizeDescription(getMyApplication());
String eName = name.replace("\n", " ");
((TextView) view.findViewById(R.id.map_name)).setText(eName);
((TextView) view.findViewById(R.id.map_descr)).setText(d);
@ -122,9 +123,9 @@ public class DashUpdatesFragment extends DashBaseFragment {
public void onClick(View view) {
if (getDownloadActivity().isInQueue(item)) {
getDownloadActivity().removeFromQueue(item);
((ImageButton)view).setImageResource(R.drawable.download_button);
((ImageButton) view).setImageResource(R.drawable.download_button);
} else if (!getDownloadActivity().startDownload(item)) {
((ImageButton)view).setImageResource(R.drawable.cancel_button);
((ImageButton) view).setImageResource(R.drawable.cancel_button);
}
}
});
@ -144,7 +145,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
if (basicProgressAsyncTask == null) {
return;
}
//needed when rotation is performed and progress can be null
// needed when rotation is performed and progress can be null
if (!updateOnlyProgress) {
getProgressIfPossible(basicProgressAsyncTask.getDescription());
}
@ -163,9 +164,8 @@ public class DashUpdatesFragment extends DashBaseFragment {
return;
}
cancelButton.setImageResource(R.drawable.cancel_button);
View view = (View)cancelButton.getParent();
if (view != null &&
view.findViewById(R.id.map_descr) != null){
View view = (View) cancelButton.getParent();
if (view != null && view.findViewById(R.id.map_descr) != null) {
view.findViewById(R.id.map_descr).setVisibility(View.GONE);
}
cancelButton.setOnClickListener(new View.OnClickListener() {
@ -183,7 +183,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
}
private void getProgressIfPossible(String message) {
if (getActivity() == null){
if (getActivity() == null) {
return;
}
for (int i = 0; i < baseNames.size(); i++) {

View file

@ -123,6 +123,12 @@ public class DashboardOnMap {
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
fabButton.hideFloatingActionButton();
for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) {
df.get().onCloseDash();
}
}
}
}
@ -221,6 +227,15 @@ public class DashboardOnMap {
private void addOrUpdateDashboardFragments() {
Iterator<WeakReference<DashBaseFragment>> it = fragList.iterator();
while(it.hasNext()) {
WeakReference<DashBaseFragment> df = it.next();
if(df.get() != null) {
df.get().onOpenDash();
} else {
it.remove();
}
}
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class,

View file

@ -8,25 +8,20 @@ import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.FavoritesActivity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
@ -71,19 +66,20 @@ public class DashTrackFragment extends DashBaseFragment {
});
return view;
}
@Override
public void onResume() {
super.onResume();
public void onOpenDash() {
updateEnable = true;
setupGpxFiles();
}
@Override
public void onPause() {
super.onPause();
public void onCloseDash() {
updateEnable = false;
}

View file

@ -37,22 +37,19 @@ public class DashOsmEditsFragment extends DashBaseFragment {
@Override
public void onResume() {
super.onResume();
public void onOpenDash() {
if (plugin == null) {
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
}
setupEditings();
setupEditings();
}
private void setupEditings() {
View mainView = getView();
if (plugin == null){
mainView.setVisibility(View.GONE);
return;
}
}
}

View file

@ -31,4 +31,9 @@ public class DashOsmoFragment extends DashBaseFragment {
return view;
}
@Override
public void onOpenDash() {
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
}
}

View file

@ -20,8 +20,7 @@ import net.osmand.plus.helpers.FontCache;
import net.osmand.util.MapUtils;
/**
* Created by Denis on
* 26.01.2015.
* Created by Denis on 26.01.2015.
*/
public class DashParkingFragment extends DashLocationFragment {
ParkingPositionPlugin plugin;
@ -49,24 +48,19 @@ public class DashParkingFragment extends DashLocationFragment {
}
@Override
public void onResume() {
super.onResume();
public void onOpenDash() {
plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
loc = getMyApplication().getSettings().getLastKnownMapLocation();
} else {
loc = new LatLon(0f, 0f);
}
updateParkingPosition();
}
private void updateParkingPosition() {
View mainView = getView();
if (plugin == null || plugin.getParkingPosition() == null){
if (plugin == null || plugin.getParkingPosition() == null) {
mainView.setVisibility(View.GONE);
return;
} else {
@ -75,16 +69,16 @@ public class DashParkingFragment extends DashLocationFragment {
LatLon position = plugin.getParkingPosition();
int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(),
loc.getLatitude(), loc.getLongitude()));
int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(), loc.getLatitude(),
loc.getLongitude()));
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
((TextView) mainView.findViewById(R.id.distance)).setText(distance);
//TODO add parking time
String parking_name = plugin.getParkingType() ?
getString(R.string.parking_place) : getString(R.string.parking_place);
// TODO add parking time
String parking_name = plugin.getParkingType() ? getString(R.string.parking_place)
: getString(R.string.parking_place);
((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null){
if (loc != null) {
direction.setVisibility(View.VISIBLE);
updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading);
}
@ -92,10 +86,10 @@ public class DashParkingFragment extends DashLocationFragment {
@Override
public boolean updateCompassValue(float value) {
if (plugin == null){
if (plugin == null) {
return true;
}
if (super.updateCompassValue(value)){
if (super.updateCompassValue(value)) {
updateParkingPosition();
}
return true;
@ -104,8 +98,7 @@ public class DashParkingFragment extends DashLocationFragment {
@Override
public void updateLocation(Location location) {
super.updateLocation(location);
if (plugin == null){
if (plugin == null) {
return;
}
updateParkingPosition();