diff --git a/OsmAnd/res/layout/tour_info.xml b/OsmAnd/res/layout/tour_info.xml
index 065126205d..a334f2291e 100644
--- a/OsmAnd/res/layout/tour_info.xml
+++ b/OsmAnd/res/layout/tour_info.xml
@@ -1,14 +1,46 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/sherpafy.xml b/OsmAnd/res/values/sherpafy.xml
index 3e0b37e1a2..c07a900ff4 100644
--- a/OsmAnd/res/values/sherpafy.xml
+++ b/OsmAnd/res/values/sherpafy.xml
@@ -1,5 +1,6 @@
+ No stages provided
Download more
No tour selected
Couldn\'t create settings file in tour folder.
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
index 555d312ee9..4ac38cfd93 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
@@ -89,7 +89,7 @@ public class OsmAndAppCustomization {
public void updatedLoadedFiles(Map indexFileNames, Map indexActivatedFileNames) {
}
- public Collection extends String> onIndexingFiles(IProgress progress, Map indexFileNames) {
+ public List onIndexingFiles(IProgress progress, Map indexFileNames) {
return Collections.emptyList();
}
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java
index bdbb273679..0563a47902 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java
@@ -202,6 +202,7 @@ public class DownloadFileHelper {
try {
final List downloadInputStreams = new ArrayList();
URL url = new URL(de.urlToDownload); //$NON-NLS-1$
+ log.debug("Url downloading " + de.urlToDownload);
downloadInputStreams.add(getInputStreamToDownload(url, forceWifi));
de.fileToDownload = de.targetFile;
if(!de.unzipFolder) {
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java
index 2be0c08bd2..35ef935ed6 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java
@@ -3,8 +3,6 @@ package net.osmand.plus.sherpafy;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -18,6 +16,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.api.FileSettingsAPIImpl;
import net.osmand.plus.download.DownloadActivityType;
+import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
@@ -27,10 +26,13 @@ import android.widget.TextView;
public class SherpafyCustomization extends OsmAndAppCustomization {
- private static final String SELECTED_TOUR = "sherpafy_tour";
+ private static final String SELECTED_TOUR = "selected_tour";
+ private static final String SELECTED_STAGE = "selected_stage";
private OsmandSettings originalSettings;
private CommonPreference selectedTourPref;
- private List tourPresent = new ArrayList();
+ private CommonPreference selectedStagePref;
+ private List tourPresent = new ArrayList();
+ private StageInformation selectedStage = null;
private TourInformation selectedTour = null;
private File toursFolder;
@@ -90,8 +92,10 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
// toursFolder, "", indexFileNames);
}
- public Collection extends String> onIndexingFiles(IProgress progress, Map indexFileNames) {
+ public List onIndexingFiles(IProgress progress, Map indexFileNames) {
ArrayList tourPresent = new ArrayList();
+ List warns = new ArrayList();
+ selectedTour = null;
if(toursFolder.exists()) {
File[] availableTours = toursFolder.listFiles();
if(availableTours != null) {
@@ -105,14 +109,14 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
final TourInformation tourInformation = new TourInformation(tr);
tourPresent.add(tourInformation);
if (selected) {
- reloadSelectedTour(progress, tr, tourInformation);
+ reloadSelectedTour(progress, tr, tourInformation, warns);
}
}
}
}
}
this.tourPresent = tourPresent;
- return Collections.emptyList();
+ return warns;
}
public List getTourInformations() {
@@ -123,7 +127,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
return selectedTour;
}
- private void reloadSelectedTour(IProgress progress, File tr, final TourInformation tourInformation) {
+ private void reloadSelectedTour(IProgress progress, File tr, final TourInformation tourInformation, List warns) {
if(progress != null) {
progress.startTask(app.getString(R.string.indexing_tour, tr.getName()), -1);
}
@@ -136,19 +140,46 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
}
app.getSettings().setSettingsAPI(fapi);
} catch (IOException e) {
+ warns.add(app.getString(R.string.settings_file_create_error));
app.showToastMessage(R.string.settings_file_create_error);
}
- tourInformation.loadFullInformation();
+ selectedStagePref = app.getSettings().registerStringPreference(SELECTED_STAGE, null).makeGlobal();
+ try {
+ tourInformation.loadFullInformation();
+ } catch (Exception e) {
+ warns.add("Selected tour : " + e.getMessage());
+ }
selectedTour = tourInformation;
+ if(selectedStagePref.get() != null) {
+ for(StageInformation s : selectedTour.getStageInformation()) {
+ if(s.getName().equals(selectedStagePref.get())) {
+ selectedStage = s;
+ break;
+ }
+ }
+ }
+ }
+
+ public StageInformation getSelectedStage() {
+ return selectedStage;
}
+ public void selectStage(StageInformation tour, IProgress progress) {
+ if(tour == null) {
+ selectedStagePref.set(null);
+ } else {
+ selectedStagePref.set(tour.getName());
+ }
+ }
- public void selectTour(TourInformation tour) {
+ public void selectTour(TourInformation tour, IProgress progress) {
if(tour == null) {
selectedTourPref.set(null);
} else {
selectedTourPref.set(tour.getName());
}
- app.getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS);
+ selectedTour = null;
+ selectedStage = null;
+ app.getResourceManager().reloadIndexes(progress);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourCommonActivity.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourCommonActivity.java
index 112d07e107..682d515d41 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourCommonActivity.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourCommonActivity.java
@@ -5,10 +5,13 @@ import java.util.ArrayList;
import java.util.List;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
+import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
@@ -57,6 +60,43 @@ public class TourCommonActivity extends SherlockFragmentActivity {
}
}
+ public void selectTour(TourInformation ti){
+ final SherpafyCustomization c = (SherpafyCustomization) ((OsmandApplication) getApplication()).getAppCustomization();
+
+ new AsyncTask (){
+ private ProgressDialogImplementation dlg;
+
+ protected void onPreExecute() {
+ dlg = ProgressDialogImplementation.createProgressDialog(TourCommonActivity.this, "", getString(R.string.indexing_tour, ""),
+ ProgressDialog.STYLE_SPINNER);
+
+ };
+
+ @Override
+ protected Void doInBackground(TourInformation... params) {
+ c.selectTour(params[0], dlg);
+ return null;
+ }
+
+ protected void onPostExecute(Void result) {
+ dlg.getDialog().dismiss();
+ for(WeakReference ref : fragList) {
+ Fragment f = ref.get();
+ if(f instanceof TourFragment) {
+ if(!f.isDetached()) {
+ ((TourFragment) f).refreshTour();
+ }
+ }
+ }
+ };
+ }.execute(ti);
+ }
+
+ public interface TourFragment {
+
+ public void refreshTour();
+ }
+
@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
int itemId = item.getItemId();
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java
index 7b0e30538e..e28fc654cd 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java
@@ -50,12 +50,21 @@ public class TourDownloadType extends DownloadActivityType {
return "";
}
+ @Override
+ public String getBasename(IndexItem indexItem) {
+ String fileName = indexItem.getFileName().replace('_', ' ');
+ if(fileName.indexOf('.') != -1) {
+ return fileName.substring(0, fileName.indexOf('.'));
+ }
+ return fileName;
+ }
+
public String getVisibleName(IndexItem indexItem, Context ctx, OsmandRegions osmandRegions) {
- return getBasename(indexItem) + "\n" + indexItem.getDescription();
+ return getBasename(indexItem).replace('_', ' ') + "\n" + indexItem.getDescription();
}
public String getTargetFileName(IndexItem item) {
- return item.getBasename();
+ return getBasename(item);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
index 6f9ab23642..c79bc14556 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
@@ -1,59 +1,117 @@
package net.osmand.plus.sherpafy;
-import java.io.BufferedReader;
+import java.io.BufferedInputStream;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
+import net.osmand.PlatformUtil;
+
+import org.xmlpull.v1.XmlPullParser;
+
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class TourInformation {
+ final String FILE_PREFIX = "@file:";
private String name;
private File folder;
- private String description = null;
+ private String shortDescription = "";
+ private String fulldescription = "";
+ private Bitmap defaultImg = null;
+ private File imgFile;
private List stageInformation = new ArrayList();
public TourInformation(File f) {
this.folder = f;
- this.name = f.getName();
+ this.name = f.getName().replace('_', ' ');
}
- private String loadDescription() {
- File fl = new File(folder, "description.txt");
- StringBuilder text = new StringBuilder();
- if (fl.exists()) {
- try {
- BufferedReader in = new BufferedReader(new FileReader(fl), 256); //$NON-NLS-1$
- String s;
- boolean f = true;
- while ((s = in.readLine()) != null) {
- if (!f) {
- text.append("\n"); //$NON-NLS-1$
- } else {
- f = false;
- }
- text.append(s);
+ private static Reader getUTF8Reader(InputStream f) throws IOException {
+ BufferedInputStream bis = new BufferedInputStream(f);
+ assert bis.markSupported();
+ bis.mark(3);
+ boolean reset = true;
+ byte[] t = new byte[3];
+ bis.read(t);
+ if (t[0] == ((byte) 0xef) && t[1] == ((byte) 0xbb) && t[2] == ((byte) 0xbf)) {
+ reset = false;
+ }
+ if (reset) {
+ bis.reset();
+ }
+ return new InputStreamReader(bis, "UTF-8");
+ }
+
+ public void loadFullInformation() throws Exception {
+ XmlPullParser parser = PlatformUtil.newXMLPullParser();
+ final Reader reader = getUTF8Reader(new FileInputStream(new File(folder, "inventory.xml")));
+ parser.setInput(reader); //$NON-NLS-1$
+ int tok;
+ String text = "";
+ StageInformation stage = null;
+ stageInformation.clear();
+ while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
+ if (tok == XmlPullParser.START_TAG) {
+ String tag = parser.getName();
+ if(tag.equals("tour")) {
+ name = getDefAttribute(parser, "name", name);
+ } else if (tag.equals("stage")) {
+ String name = getDefAttribute(parser, "name", "");
+ stage = new StageInformation();
+ stage.name = name;
}
- in.close();
- } catch (IOException e) {
- e.printStackTrace();
+ } else if (tok == XmlPullParser.TEXT) {
+ text = parser.getText();
+ } else if (tok == XmlPullParser.END_TAG) {
+ String tag = parser.getName();
+ if(tag.equals("stage")) {
+ stageInformation.add(stage);
+ stage = null;
+ } else if(stage != null && tag.equals("description")) {
+ stage.description = text;
+ } else if(stage != null && tag.equals("gpx")) {
+ if(text.startsWith(FILE_PREFIX)) {
+ stage.gpxFile = new File(folder, text.substring(FILE_PREFIX.length()));
+ }
+ } else if(tag.equals("fullDescription")) {
+ fulldescription = text;
+ } else if(tag.equals("shortDescription")) {
+ shortDescription = text;
+ } else if(tag.equals("defaultImage")) {
+ if(text.startsWith(FILE_PREFIX)) {
+ imgFile = new File(folder, text.substring(FILE_PREFIX.length()));
+ }
+ }
+ text = "";
}
}
- return text.toString();
+ reader.close();
}
- public void loadFullInformation(){
- description = loadDescription();
+ private String getDefAttribute(XmlPullParser parser, String string, String def) {
+ String vl = parser.getAttributeValue("", string);
+ if(vl != null && vl.length() > 0) {
+ return vl;
+ }
+ return def;
+
+ }
+
+
+ public String getShortDescription() {
+ return shortDescription;
}
-
- public String getDescription() {
- return description == null ? "" : description;
+ public String getFulldescription() {
+ return fulldescription;
}
public String getName() {
@@ -70,18 +128,17 @@ public class TourInformation {
public Bitmap getImageBitmap() {
- File fl = new File(folder, "images/Default.jpg");
- if(fl.exists()) {
- return BitmapFactory.decodeFile(fl.getAbsolutePath());
+ if(defaultImg == null && imgFile != null && imgFile.exists()) {
+ defaultImg = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
}
- return null;
+ return defaultImg;
}
public static class StageInformation {
File gpxFile;
- String name;
- String description;
+ String name = "";
+ String description = "";
public String getName() {
return name;
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformationFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformationFragment.java
index 4b90cbfc34..44683f4fec 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformationFragment.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformationFragment.java
@@ -5,23 +5,24 @@ package net.osmand.plus.sherpafy;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
+import net.osmand.plus.sherpafy.TourCommonActivity.TourFragment;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
+import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragment;
-public class TourInformationFragment extends SherlockFragment {
+public class TourInformationFragment extends SherlockFragment implements TourFragment {
private View view;
private SherpafyCustomization appCtx;
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.tour_info, container, false);
setHasOptionsMenu(true);
-
appCtx = (SherpafyCustomization) getApp().getAppCustomization();
return view;
}
@@ -29,16 +30,26 @@ public class TourInformationFragment extends SherlockFragment {
@Override
public void onResume() {
super.onResume();
- TextView description = (TextView) view.findViewById(R.id.tour_description);
+ updateView();
+ }
+
+ private void updateView() {
ImageView img = (ImageView) view.findViewById(R.id.tour_image);
+ TextView description = (TextView) view.findViewById(R.id.tour_description);
+ TextView fullDescription = (TextView) view.findViewById(R.id.tour_fulldescription);
TextView name = (TextView) view.findViewById(R.id.tour_name);
if(appCtx.getSelectedTour() != null) {
name.setText(appCtx.getSelectedTour().getName());
- description.setText(appCtx.getSelectedTour().getDescription());
+ description.setText(appCtx.getSelectedTour().getShortDescription());
description.setVisibility(View.VISIBLE);
+ fullDescription.setText(appCtx.getSelectedTour().getFulldescription());
+ fullDescription.setVisibility(View.VISIBLE);
final Bitmap imageBitmap = appCtx.getSelectedTour().getImageBitmap();
if(imageBitmap != null) {
img.setImageBitmap(imageBitmap);
+ img.setAdjustViewBounds(true);
+ img.setScaleType(ScaleType.CENTER_INSIDE);
+ img.setCropToPadding(true);
img.setVisibility(View.VISIBLE);
} else {
img.setVisibility(View.GONE);
@@ -47,6 +58,7 @@ public class TourInformationFragment extends SherlockFragment {
name.setText(R.string.no_tour_selected);
img.setVisibility(View.GONE);
description.setVisibility(View.GONE);
+ fullDescription.setVisibility(View.GONE);
}
}
@@ -54,6 +66,11 @@ public class TourInformationFragment extends SherlockFragment {
public OsmandApplication getApp(){
return (OsmandApplication) getSherlockActivity().getApplication();
}
+
+ @Override
+ public void refreshTour() {
+ updateView();
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourSelectionFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourSelectionFragment.java
index 46592eb5f9..c15a7024cd 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourSelectionFragment.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourSelectionFragment.java
@@ -7,8 +7,7 @@ import java.util.List;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
-import net.osmand.plus.TargetPointsHelper;
-import net.osmand.plus.activities.SettingsActivity;
+import net.osmand.plus.sherpafy.TourCommonActivity.TourFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -26,7 +25,7 @@ import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
-public class TourSelectionFragment extends SherlockListFragment {
+public class TourSelectionFragment extends SherlockListFragment implements TourFragment {
public static final int REQUEST_POI_EDIT = 55;
private static final int DOWNLOAD_MORE = 0;
private SherpafyCustomization appCtx;
@@ -59,10 +58,10 @@ public class TourSelectionFragment extends SherlockListFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
final OsmandApplication app = (OsmandApplication) getActivity().getApplication();
- boolean light = app.getSettings().isLightActionBar();
com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, DOWNLOAD_MORE, 0, R.string.download_more).setShowAsActionFlags(
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdown_light : R.drawable.ic_action_gdown_dark);
+// boolean light = app.getSettings().isLightActionBar();
+ // menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdown_light : R.drawable.ic_action_gdown_dark);
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) {
@@ -77,9 +76,9 @@ public class TourSelectionFragment extends SherlockListFragment {
public void onListItemClick(ListView parent, View v, int position, long id) {
final TourInformation tour = ((LocalAdapter) getListAdapter()).getItem(position);
if(appCtx.getSelectedTour() != tour) {
- appCtx.selectTour(tour);
+ ((TourCommonActivity) getActivity()).selectTour(tour);
} else {
- appCtx.selectTour(null);
+ ((TourCommonActivity) getActivity()).selectTour(null);
}
}
@@ -106,8 +105,8 @@ public class TourSelectionFragment extends SherlockListFragment {
} else {
check.setVisibility(View.INVISIBLE);
}
- if(model.getDescription().length() > 0) {
- label.setText(model.getName() +"\n" + model.getDescription());
+ if(model.getShortDescription().length() > 0) {
+ label.setText(model.getName() +"\n" + model.getShortDescription());
} else {
label.setText(model.getName());
}
@@ -116,4 +115,10 @@ public class TourSelectionFragment extends SherlockListFragment {
}
+ @Override
+ public void refreshTour() {
+ setListAdapter(new LocalAdapter(appCtx.getTourInformations()));
+
+ }
+
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourStageFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourStageFragment.java
index 34cde31903..02ca73dd1c 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourStageFragment.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourStageFragment.java
@@ -6,8 +6,10 @@ package net.osmand.plus.sherpafy;
import java.util.ArrayList;
import java.util.List;
+import net.osmand.IProgress;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
+import net.osmand.plus.sherpafy.TourCommonActivity.TourFragment;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -21,7 +23,7 @@ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockListFragment;
-public class TourStageFragment extends SherlockListFragment {
+public class TourStageFragment extends SherlockListFragment implements TourFragment {
public static final int REQUEST_POI_EDIT = 55;
private SherpafyCustomization appCtx;
private boolean lightContent;
@@ -42,11 +44,11 @@ public class TourStageFragment extends SherlockListFragment {
// return false;
// }
// });
+ setEmptyText(getString(R.string.no_stages_provided));
if(appCtx.getSelectedTour() != null) {
setListAdapter(new LocalAdapter(appCtx.getSelectedTour().getStageInformation()));
} else {
setListAdapter(new LocalAdapter(new ArrayList()));
- setEmptyText(getString(R.string.no_tour_selected));
}
}
@@ -57,7 +59,7 @@ public class TourStageFragment extends SherlockListFragment {
@Override
public void onListItemClick(ListView parent, View v, int position, long id) {
final StageInformation model = ((LocalAdapter) getListAdapter()).getItem(position);
- // TODO
+ appCtx.selectStage(model, IProgress.EMPTY_PROGRESS);
}
private class LocalAdapter extends ArrayAdapter {
@@ -76,8 +78,13 @@ public class TourStageFragment extends SherlockListFragment {
ImageView icon = (ImageView) row.findViewById(R.id.icon);
ImageView check = (ImageView) row.findViewById(R.id.check_item);
icon.setImageResource(!lightContent ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_fav_light);
- check.setImageResource(!lightContent ? R.drawable.ic_action_ok_dark : R.drawable.ic_action_ok_light);
final StageInformation model = getItem(position);
+ if(appCtx.getSelectedStage() == model) {
+ check.setImageResource(!lightContent ? R.drawable.ic_action_ok_dark : R.drawable.ic_action_ok_light);
+ check.setVisibility(View.VISIBLE);
+ } else {
+ check.setVisibility(View.INVISIBLE);
+ }
if(model.getDescription().length() > 0) {
label.setText(model.getName() +"\n" + model.getDescription());
} else {
@@ -88,4 +95,14 @@ public class TourStageFragment extends SherlockListFragment {
}
+ @Override
+ public void refreshTour() {
+ if(appCtx.getSelectedTour() != null) {
+ setListAdapter(new LocalAdapter(appCtx.getSelectedTour().getStageInformation()));
+ } else {
+ setListAdapter(new LocalAdapter(new ArrayList()));
+ }
+
+ }
+
}