Add update dashboard method
This commit is contained in:
parent
9882da1594
commit
7fb1bee03a
16 changed files with 161 additions and 186 deletions
|
@ -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;
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class DashDownloadMapsFragment extends DashBaseFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onOpenUpdate() {
|
||||
public void onOpenDash() {
|
||||
refreshData();
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,6 @@ public class DashErrorFragment extends DashBaseFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onOpenUpdate() {
|
||||
public void onOpenDash() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
@ -70,25 +69,16 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
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() {
|
||||
View mainView = getView();
|
||||
final FavouritesDbHelper helper = getMyApplication().getFavorites();
|
||||
|
@ -105,10 +95,10 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
@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()));
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
@ -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) {
|
||||
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()));
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -61,6 +61,13 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloaderC
|
|||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
if (!getMyApplication().isApplicationInitializing()) {
|
||||
updateMapImage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_map_fragment, container, false);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
@ -72,10 +71,8 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onOpenDash() {
|
||||
// This is used as origin for both Fav-list and direction arrows
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
|
@ -85,14 +82,10 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
setupRecents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -110,22 +103,20 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
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,8 +131,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +50,8 @@ 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);
|
||||
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,8 +77,8 @@ 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();
|
||||
|
@ -91,7 +89,8 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
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);
|
||||
|
@ -164,8 +165,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
}
|
||||
cancelButton.setImageResource(R.drawable.cancel_button);
|
||||
View view = (View) cancelButton.getParent();
|
||||
if (view != null &&
|
||||
view.findViewById(R.id.map_descr) != null){
|
||||
if (view != null && view.findViewById(R.id.map_descr) != null) {
|
||||
view.findViewById(R.id.map_descr).setVisibility(View.GONE);
|
||||
}
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
@ -73,20 +68,21 @@ public class DashTrackFragment extends DashBaseFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onOpenDash() {
|
||||
updateEnable = true;
|
||||
setupGpxFiles();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onCloseDash() {
|
||||
updateEnable = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void setupGpxFiles() {
|
||||
View mainView = getView();
|
||||
final File dir = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
private void setupEditings() {
|
||||
View mainView = getView();
|
||||
if (plugin == null){
|
||||
mainView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,9 @@ public class DashOsmoFragment extends DashBaseFragment {
|
|||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,18 +48,13 @@ 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();
|
||||
}
|
||||
|
||||
|
@ -75,13 +69,13 @@ 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);
|
||||
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) {
|
||||
|
@ -104,7 +98,6 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
super.updateLocation(location);
|
||||
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue