Merge pull request #684 from Bars107/master
Large updation to description filed in stage.
This commit is contained in:
commit
52c6fc5da5
3 changed files with 70 additions and 11 deletions
|
@ -233,8 +233,11 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
}
|
||||
selectedTour = null;
|
||||
selectedStage = null;
|
||||
selectedStagePref.set(null);
|
||||
app.getResourceManager().reloadIndexes(progress);
|
||||
//to avoid null reference ecxeption if there's no selected tour yet.
|
||||
if (selectedStagePref != null) {
|
||||
selectedStagePref.set(null);
|
||||
}
|
||||
app.getResourceManager().reloadIndexes(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class TourInformation {
|
||||
final String FILE_PREFIX = "@file:";
|
||||
|
@ -68,6 +69,10 @@ public class TourInformation {
|
|||
String name = getDefAttribute(parser, "name", "");
|
||||
stage = new StageInformation();
|
||||
stage.name = name;
|
||||
} else if (tag.equals("fullDescription")){
|
||||
fulldescription = getInnerXml(parser);
|
||||
} else if (stage != null && tag.equals("description")){
|
||||
stage.description = getInnerXml(parser);
|
||||
}
|
||||
} else if (tok == XmlPullParser.TEXT) {
|
||||
text = parser.getText();
|
||||
|
@ -76,8 +81,6 @@ public class TourInformation {
|
|||
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("fullDescription")) {
|
||||
stage.fullDescription = text;
|
||||
} else if(stage != null && tag.equals("image")) {
|
||||
|
@ -145,6 +148,15 @@ public class TourInformation {
|
|||
}
|
||||
return defaultImg;
|
||||
}
|
||||
|
||||
//returns image bitmap from selected relative path
|
||||
public Bitmap getImageBitmapFromPath(String path){
|
||||
File imgFile = getFile(path);
|
||||
if (imgFile != null){
|
||||
return BitmapFactory.decodeFile(imgFile.getAbsolutePath())
|
||||
; }
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class StageInformation {
|
||||
|
||||
|
@ -186,4 +198,35 @@ public class TourInformation {
|
|||
|
||||
}
|
||||
|
||||
//Returns full string from which contains XML tags from XMLParser
|
||||
public static String getInnerXml(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int depth = 1;
|
||||
while (depth != 0) {
|
||||
switch (parser.next()) {
|
||||
case XmlPullParser.END_TAG:
|
||||
depth--;
|
||||
if (depth > 0) {
|
||||
sb.append("</" + parser.getName() + ">");
|
||||
}
|
||||
break;
|
||||
case XmlPullParser.START_TAG:
|
||||
depth++;
|
||||
StringBuilder attrs = new StringBuilder();
|
||||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||
attrs.append(parser.getAttributeName(i) + "=\""
|
||||
+ parser.getAttributeValue(i) + "\" ");
|
||||
}
|
||||
sb.append("<" + parser.getName() + " " + attrs.toString() + ">");
|
||||
break;
|
||||
default:
|
||||
sb.append(parser.getText());
|
||||
break;
|
||||
}
|
||||
}
|
||||
String content = sb.toString();
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Html;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
|
@ -57,7 +61,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
TextView fullDescription;
|
||||
RadioGroup stages;
|
||||
private ToggleButton collapser;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -135,16 +138,27 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
if (customization.getSelectedStage() == null) {
|
||||
if (customization.getSelectedTour() != null) {
|
||||
TourInformation curTour = customization.getSelectedTour();
|
||||
fullDescription.setText(curTour.getFulldescription());
|
||||
description.setText((curTour.getShortDescription()));
|
||||
fullDescription.setText(Html.fromHtml(curTour.getFulldescription()));
|
||||
description.setText(Html.fromHtml(curTour.getShortDescription()));
|
||||
// ((TextView)findViewById(R.id.tour_name)).setText(getString(R.string.overview));
|
||||
setCollapserText(getString(R.string.overview));
|
||||
prepareBitmap(curTour.getImageBitmap());
|
||||
}
|
||||
} else {
|
||||
StageInformation st = customization.getSelectedStage();
|
||||
description.setText(st.getDescription());
|
||||
fullDescription.setText(st.getFullDescription());
|
||||
description.setText(Html.fromHtml(st.getDescription(), new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String s) {
|
||||
|
||||
Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s);
|
||||
Drawable bmp = new BitmapDrawable(getResources(),file);
|
||||
bmp.setBounds(0,0, bmp.getIntrinsicHeight(), bmp.getIntrinsicHeight());
|
||||
return bmp;
|
||||
}
|
||||
|
||||
}, null));
|
||||
|
||||
fullDescription.setText(Html.fromHtml(st.getFullDescription()));
|
||||
// ((TextView)findViewById(R.id.tour_name)).setText(st.getName());
|
||||
setCollapserText(st.getName());
|
||||
prepareBitmap(st.getImageBitmap());
|
||||
|
@ -257,7 +271,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
} else {
|
||||
stages.check(0);
|
||||
}
|
||||
// updateTourContentView();
|
||||
}
|
||||
|
||||
private void goToMap() {
|
||||
|
@ -447,7 +460,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
try {
|
||||
dlg.dismiss();
|
||||
} catch (Exception ex){
|
||||
|
||||
ex.printStackTrace();
|
||||
}
|
||||
startTourView();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue