Fix tour selection
This commit is contained in:
parent
3e9b7be35e
commit
383ffec6a0
2 changed files with 17 additions and 27 deletions
|
@ -22,7 +22,6 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.api.FileSettingsAPIImpl;
|
import net.osmand.plus.api.FileSettingsAPIImpl;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -226,18 +225,18 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
||||||
|
|
||||||
|
|
||||||
public void selectTour(TourInformation tour, IProgress progress) {
|
public void selectTour(TourInformation tour, IProgress progress) {
|
||||||
if(tour == null) {
|
if (tour == null) {
|
||||||
selectedTourPref.set(null);
|
selectedTourPref.set(null);
|
||||||
} else {
|
} else {
|
||||||
selectedTourPref.set(tour.getName());
|
selectedTourPref.set(tour.getName());
|
||||||
}
|
}
|
||||||
selectedTour = null;
|
selectedTour = null;
|
||||||
selectedStage = null;
|
selectedStage = null;
|
||||||
//to avoid null reference ecxeption if there's no selected tour yet.
|
// to avoid null reference ecxeption if there's no selected tour yet.
|
||||||
if (selectedStagePref != null) {
|
if (selectedStagePref != null) {
|
||||||
selectedStagePref.set(null);
|
selectedStagePref.set(null);
|
||||||
}
|
}
|
||||||
app.getResourceManager().reloadIndexes(progress);
|
app.getResourceManager().reloadIndexes(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package net.osmand.plus.sherpafy;
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
|
@ -19,16 +20,11 @@ import android.app.AlertDialog.Builder;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Matrix;
|
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.BitmapFactory.Options;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
@ -43,7 +39,6 @@ import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
@ -75,7 +70,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
RadioGroup stages;
|
RadioGroup stages;
|
||||||
private ToggleButton collapser;
|
private ToggleButton collapser;
|
||||||
Point size;
|
Point size;
|
||||||
private boolean afterDownload = false;
|
private Set<TourInformation> currentTourInformations = new HashSet<TourInformation>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -147,23 +142,19 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
//this flag needed to start indexing tours is user downloaded some and returned to activity
|
TourInformation selectedTour = customization.getSelectedTour();
|
||||||
if (afterDownload){
|
if (selectedTour == null || currentTourInformations.contains(selectedTour)) {
|
||||||
if (customization.getTourInformations().isEmpty()){
|
for (TourInformation i : customization.getTourInformations()) {
|
||||||
customization.onIndexingFiles(IProgress.EMPTY_PROGRESS,new LinkedHashMap<String, String>());
|
if (!currentTourInformations.contains(i)) {
|
||||||
}
|
currentTourInformations.add(i);
|
||||||
|
selectedTour = i;
|
||||||
if (!customization.getTourInformations().isEmpty()){
|
|
||||||
if (customization.getSelectedTour() == null){
|
|
||||||
setTourSelectionContentView();
|
|
||||||
state = STATE_SELECT_TOUR;
|
|
||||||
} else {
|
|
||||||
startTourView();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(selectedTour != null) {
|
||||||
|
selectTourAsync(selectedTour);
|
||||||
|
//startTourView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTourInfoContent() {
|
private void setTourInfoContent() {
|
||||||
|
@ -374,6 +365,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
private void goToMap() {
|
private void goToMap() {
|
||||||
if (customization.getSelectedStage() != null) {
|
if (customization.getSelectedStage() != null) {
|
||||||
GPXFile gpx = customization.getSelectedStage().getGpx();
|
GPXFile gpx = customization.getSelectedStage().getGpx();
|
||||||
|
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||||
if (gpx != null && gpx.findPointToShow() != null) {
|
if (gpx != null && gpx.findPointToShow() != null) {
|
||||||
WptPt p = gpx.findPointToShow();
|
WptPt p = gpx.findPointToShow();
|
||||||
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon,
|
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon,
|
||||||
|
@ -483,7 +475,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
private void startDownloadActivity() {
|
private void startDownloadActivity() {
|
||||||
final Intent download = new Intent(this, DownloadIndexActivity.class);
|
final Intent download = new Intent(this, DownloadIndexActivity.class);
|
||||||
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
afterDownload = true;
|
|
||||||
startActivity(download);
|
startActivity(download);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue