Sherpafy Update
This commit is contained in:
parent
f20e27d913
commit
9263b3eb58
8 changed files with 291 additions and 33 deletions
|
@ -1,5 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="sherpafy_stage_tab_fav">Fav</string>
|
||||||
|
<string name="sherpafy_stage_tab_target">Target</string>
|
||||||
|
<string name="sherpafy_stage_tab_route">Route</string>
|
||||||
|
<string name="sherpafy_stage_tab_info">Info</string>
|
||||||
<string name="sherpafy_tour_info_txt">Tour Information</string>
|
<string name="sherpafy_tour_info_txt">Tour Information</string>
|
||||||
<string name="sherpafy_stages_txt">Stages</string>
|
<string name="sherpafy_stages_txt">Stages</string>
|
||||||
<string name="sherpafy_instructions">Instructions</string>
|
<string name="sherpafy_instructions">Instructions</string>
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class SherpafyHtmlFragment extends SherlockFragment {
|
||||||
wv = new WebView(getActivity());
|
wv = new WebView(getActivity());
|
||||||
WebSettings settings = wv.getSettings();
|
WebSettings settings = wv.getSettings();
|
||||||
settings.setDefaultTextEncodingName("utf-8");
|
settings.setDefaultTextEncodingName("utf-8");
|
||||||
|
setHasOptionsMenu(true);
|
||||||
return wv;
|
return wv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public class SherpafyHtmlFragment extends SherlockFragment {
|
||||||
if(tl != null){
|
if(tl != null){
|
||||||
getSherlockActivity().getSupportActionBar().setTitle(tl);
|
getSherlockActivity().getSupportActionBar().setTitle(tl);
|
||||||
}
|
}
|
||||||
wv.loadData("<html><body>"+data+"</body></html", "text/html", "utf-8");
|
wv.loadData("<html><body>"+data+"</body></html", "text/html; charset=utf-8", "utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||||
|
|
|
@ -1,29 +1,36 @@
|
||||||
package net.osmand.plus.sherpafy;
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Html.ImageGetter;
|
import android.text.Html.ImageGetter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
import android.widget.TabHost.TabSpec;
|
||||||
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragment;
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
@ -40,6 +47,8 @@ public class SherpafyStageFragment extends SherlockFragment {
|
||||||
private StageInformation stage;
|
private StageInformation stage;
|
||||||
private TourInformation tour;
|
private TourInformation tour;
|
||||||
private View view;
|
private View view;
|
||||||
|
private TabHost tabHost;
|
||||||
|
private TabsAdapter mTabsAdapter;
|
||||||
|
|
||||||
public SherpafyStageFragment() {
|
public SherpafyStageFragment() {
|
||||||
}
|
}
|
||||||
|
@ -97,26 +106,20 @@ public class SherpafyStageFragment extends SherlockFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.sherpafy_stage_info, container, false);
|
view = inflater.inflate(R.layout.tab_content, container, false);
|
||||||
WebView description = (WebView) view.findViewById(R.id.Description);
|
tabHost = (TabHost) view.findViewById(android.R.id.tabhost);
|
||||||
ImageView icon = (ImageView) view.findViewById(R.id.Icon);
|
tabHost.setup();
|
||||||
TextView additional = (TextView) view.findViewById(R.id.AdditionalText);
|
|
||||||
TextView text = (TextView) view.findViewById(R.id.Text);
|
|
||||||
TextView header = (TextView) view.findViewById(R.id.HeaderText);
|
|
||||||
|
|
||||||
if(stage.getImageBitmap() != null) {
|
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.pager);
|
||||||
icon.setImageBitmap(stage.getImageBitmap()) ;
|
mTabsAdapter = new TabsAdapter(getSherlockActivity(), tabHost, mViewPager);
|
||||||
} else {
|
mTabsAdapter.addTab(tabHost.newTabSpec("INFO").setIndicator(getString(R.string.sherpafy_stage_tab_info)),
|
||||||
icon.setVisibility(View.GONE);
|
SherpafyStageInfoFragment.class, null);
|
||||||
}
|
mTabsAdapter.addTab(tabHost.newTabSpec("ROUTE").setIndicator(getString(R.string.sherpafy_stage_tab_route)),
|
||||||
if (stage.getDistance() > 0) {
|
SherpafyStageItineraryFragment.class, null);
|
||||||
additional.setText(OsmAndFormatter.getFormattedDistance((float) stage.getDistance(), getMyApplication()));
|
mTabsAdapter.addTab(tabHost.newTabSpec("FAV").setIndicator(getString(R.string.sherpafy_stage_tab_fav)),
|
||||||
} else {
|
SherpafyStageInfoFragment.class, null);
|
||||||
additional.setText("");
|
mTabsAdapter.addTab(tabHost.newTabSpec("TARGET").setIndicator(getString(R.string.sherpafy_stage_tab_target)),
|
||||||
}
|
SherpafyStageItineraryFragment.class, null);
|
||||||
header.setText(stage.getName());
|
|
||||||
text.setText(stage.getShortDescription());
|
|
||||||
description.loadData("<html><body>" + stage.getFullDescription() + "</body></html", "text/html", "utf-8");
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,4 +205,111 @@ public class SherpafyStageFragment extends SherlockFragment {
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a helper class that implements the management of tabs and all
|
||||||
|
* details of connecting a ViewPager with associated TabHost. It relies on a
|
||||||
|
* trick. Normally a tab host has a simple API for supplying a View or
|
||||||
|
* Intent that each tab will show. This is not sufficient for switching
|
||||||
|
* between pages. So instead we make the content part of the tab host
|
||||||
|
* 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
|
||||||
|
* view to show as the tab content. It listens to changes in tabs, and takes
|
||||||
|
* care of switch to the correct paged in the ViewPager whenever the selected
|
||||||
|
* tab changes.
|
||||||
|
*/
|
||||||
|
public static class TabsAdapter extends FragmentPagerAdapter
|
||||||
|
implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {
|
||||||
|
private final Context mContext;
|
||||||
|
private final TabHost mTabHost;
|
||||||
|
private final ViewPager mViewPager;
|
||||||
|
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||||
|
|
||||||
|
static final class TabInfo {
|
||||||
|
private final String tag;
|
||||||
|
private Class<?> clss;
|
||||||
|
private Bundle args;
|
||||||
|
|
||||||
|
TabInfo(String _tag, Class<?> _class, Bundle _args) {
|
||||||
|
tag = _tag;
|
||||||
|
clss = _class;
|
||||||
|
args = _args;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class DummyTabFactory implements TabHost.TabContentFactory {
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
|
public DummyTabFactory(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View createTabContent(String tag) {
|
||||||
|
View v = new View(mContext);
|
||||||
|
v.setMinimumWidth(0);
|
||||||
|
v.setMinimumHeight(0);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabsAdapter(FragmentActivity activity, TabHost tabHost,ViewPager pager) {
|
||||||
|
super(activity.getSupportFragmentManager());
|
||||||
|
mContext = activity;
|
||||||
|
mTabHost = tabHost;
|
||||||
|
mViewPager = pager;
|
||||||
|
mTabHost.setOnTabChangedListener(this);
|
||||||
|
mViewPager.setAdapter(this);
|
||||||
|
mViewPager.setOnPageChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabSpec addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
|
||||||
|
tabSpec.setContent(new DummyTabFactory(mContext));
|
||||||
|
String tag = tabSpec.getTag();
|
||||||
|
|
||||||
|
TabInfo info = new TabInfo(tag, clss, args);
|
||||||
|
mTabs.add(info);
|
||||||
|
mTabHost.addTab(tabSpec);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
return tabSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return mTabs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
TabInfo info = mTabs.get(position);
|
||||||
|
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabChanged(String tabId) {
|
||||||
|
int position = mTabHost.getCurrentTab();
|
||||||
|
mViewPager.setCurrentItem(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
// Unfortunately when TabHost changes the current tab, it kindly
|
||||||
|
// also takes care of putting focus on it when not in touch mode.
|
||||||
|
// The jerk.
|
||||||
|
// This hack tries to prevent this from pulling focus out of our
|
||||||
|
// ViewPager.
|
||||||
|
TabWidget widget = mTabHost.getTabWidget();
|
||||||
|
int oldFocusability = widget.getDescendantFocusability();
|
||||||
|
widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||||
|
mTabHost.setCurrentTab(position);
|
||||||
|
widget.setDescendantFocusability(oldFocusability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
|
||||||
|
public class SherpafyStageInfoFragment extends SherlockFragment {
|
||||||
|
public static final String STAGE_PARAM = "STAGE";
|
||||||
|
public static final String TOUR_PARAM = "TOUR";
|
||||||
|
OsmandApplication app;
|
||||||
|
private SherpafyCustomization customization;
|
||||||
|
protected StageInformation stage;
|
||||||
|
private TourInformation tour;
|
||||||
|
private View view;
|
||||||
|
|
||||||
|
public SherpafyStageInfoFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||||
|
customization = (SherpafyCustomization) app.getAppCustomization();
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
String id = getArguments().getString(TOUR_PARAM);
|
||||||
|
for(TourInformation ti : customization.getTourInformations()) {
|
||||||
|
if(ti.getId().equals(id)) {
|
||||||
|
tour = ti;
|
||||||
|
getSherlockActivity().getSupportActionBar().setTitle(tour.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int k = getArguments().getInt(STAGE_PARAM);
|
||||||
|
if(tour != null && tour.getStageInformation().size() > k) {
|
||||||
|
stage = tour.getStageInformation().get(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
view = inflater.inflate(R.layout.sherpafy_stage_info, container, false);
|
||||||
|
WebView description = (WebView) view.findViewById(R.id.Description);
|
||||||
|
WebSettings settings = description.getSettings();
|
||||||
|
settings.setDefaultTextEncodingName("utf-8");
|
||||||
|
ImageView icon = (ImageView) view.findViewById(R.id.Icon);
|
||||||
|
TextView additional = (TextView) view.findViewById(R.id.AdditionalText);
|
||||||
|
TextView text = (TextView) view.findViewById(R.id.Text);
|
||||||
|
TextView header = (TextView) view.findViewById(R.id.HeaderText);
|
||||||
|
|
||||||
|
updateView(description, icon, additional, text, header);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void updateView(WebView description, ImageView icon, TextView additional, TextView text, TextView header) {
|
||||||
|
if (stage.getImageBitmap() != null) {
|
||||||
|
icon.setImageBitmap(stage.getImageBitmap());
|
||||||
|
} else {
|
||||||
|
icon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if (stage.getDistance() > 0) {
|
||||||
|
additional.setText(OsmAndFormatter.getFormattedDistance((float) stage.getDistance(), getMyApplication()));
|
||||||
|
} else {
|
||||||
|
additional.setText("");
|
||||||
|
}
|
||||||
|
header.setText(stage.getName());
|
||||||
|
text.setText(stage.getShortDescription());
|
||||||
|
description.loadData("<html><body>" + stage.getFullDescription() + "</body></html", "text/html; charset=utf-8",
|
||||||
|
"utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment {
|
||||||
|
|
||||||
|
protected void updateView(WebView description, ImageView icon, TextView additional, TextView text, TextView header) {
|
||||||
|
if (stage.getItineraryBitmap() != null) {
|
||||||
|
icon.setImageBitmap(stage.getItineraryBitmap());
|
||||||
|
} else {
|
||||||
|
icon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
additional.setVisibility(View.GONE);
|
||||||
|
header.setVisibility(View.GONE);
|
||||||
|
description.loadData("<html><body>" + stage.getItinerary()
|
||||||
|
+ "</body></html", "text/html; charset=utf-8", "utf-8");
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,16 +63,22 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||||
customization = (SherpafyCustomization) app.getAppCustomization();
|
customization = (SherpafyCustomization) app.getAppCustomization();
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
String id = getArguments().getString("TOUR");
|
String id = getArguments().getString("TOUR");
|
||||||
for (TourInformation ti : customization.getTourInformations()) {
|
for (TourInformation ti : customization.getTourInformations()) {
|
||||||
if (ti.getId().equals(id)) {
|
if (ti.getId().equals(id)) {
|
||||||
tour = ti;
|
tour = ti;
|
||||||
getSherlockActivity().getSupportActionBar().setTitle(tour.getName());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if(tour != null) {
|
||||||
|
getSherlockActivity().getSupportActionBar().setTitle(tour.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -82,6 +82,12 @@ public class TourInformation {
|
||||||
String name = getDefAttribute(parser, "name", "");
|
String name = getDefAttribute(parser, "name", "");
|
||||||
stage = new StageInformation(this, stageInformation.size());
|
stage = new StageInformation(this, stageInformation.size());
|
||||||
stage.name = name;
|
stage.name = name;
|
||||||
|
} else if (tag.equals("itinerary") && stage != null){
|
||||||
|
String img = getDefAttribute(parser, "image", "");
|
||||||
|
if(img.startsWith(FILE_PREFIX)) {
|
||||||
|
stage.itineraryFile = getFile(img);
|
||||||
|
}
|
||||||
|
stage.itinerary = getInnerXml(parser);
|
||||||
} else if (tag.equals("fullDescription")){
|
} else if (tag.equals("fullDescription")){
|
||||||
fulldescription = getInnerXml(parser);
|
fulldescription = getInnerXml(parser);
|
||||||
} else if (tag.equals("instructions")){
|
} else if (tag.equals("instructions")){
|
||||||
|
@ -185,17 +191,24 @@ public class TourInformation {
|
||||||
|
|
||||||
public static class StageInformation {
|
public static class StageInformation {
|
||||||
|
|
||||||
|
String itinerary = "";
|
||||||
File gpxFile;
|
File gpxFile;
|
||||||
public GPXFile gpx;
|
public GPXFile gpx;
|
||||||
String name = "";
|
String name = "";
|
||||||
String shortDescription = "";
|
String shortDescription = "";
|
||||||
String fullDescription = "";
|
String fullDescription = "";
|
||||||
Bitmap img = null;
|
Bitmap img;
|
||||||
File imgFile;
|
File imgFile;
|
||||||
|
private Bitmap itineraryImg;
|
||||||
|
File itineraryFile;
|
||||||
double distance;
|
double distance;
|
||||||
private TourInformation tour;
|
private TourInformation tour;
|
||||||
private int order;
|
private int order;
|
||||||
|
|
||||||
|
public String getItinerary() {
|
||||||
|
return itinerary;
|
||||||
|
}
|
||||||
|
|
||||||
public TourInformation getTour() {
|
public TourInformation getTour() {
|
||||||
return tour;
|
return tour;
|
||||||
}
|
}
|
||||||
|
@ -237,6 +250,13 @@ public class TourInformation {
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bitmap getItineraryBitmap() {
|
||||||
|
if(itineraryImg == null && itineraryFile != null && itineraryFile.exists()) {
|
||||||
|
itineraryImg = BitmapFactory.decodeFile(itineraryFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
return itineraryImg;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
private ListView mDrawerList;
|
private ListView mDrawerList;
|
||||||
private ArrayAdapter<Object> drawerAdapter;
|
private ArrayAdapter<Object> drawerAdapter;
|
||||||
private WeakHashMap<Object, Fragment> fragments = new WeakHashMap<Object, Fragment>();
|
private WeakHashMap<Object, Fragment> fragments = new WeakHashMap<Object, Fragment>();
|
||||||
private Object selectedItem;
|
private static Object selectedItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -97,15 +97,14 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
displaySize = new Point();
|
displaySize = new Point();
|
||||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
||||||
|
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
||||||
|
R.string.default_buttons_other_actions, R.string.close);
|
||||||
if (getMyApplication().isApplicationInitializing()) {
|
if (getMyApplication().isApplicationInitializing()) {
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment()).commit();
|
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment()).commit();
|
||||||
} else {
|
} else {
|
||||||
showSelectedItem();
|
showSelectedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
|
||||||
R.string.default_buttons_other_actions, R.string.close);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +123,11 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
setImageResource(R.drawable.icon_sherpafy);
|
setImageResource(R.drawable.icon_sherpafy);
|
||||||
tv.setText(getString(R.string.sherpafy_tours));
|
tv.setText(getString(R.string.sherpafy_tours));
|
||||||
} else if(it instanceof TourInformation){
|
} else if(it instanceof TourInformation){
|
||||||
imView.setImageResource(R.drawable.ic_action_globus_light);
|
if(selectedItem == it) {
|
||||||
|
imView.setImageResource(R.drawable.ic_action_ok_light);
|
||||||
|
} else {
|
||||||
|
imView.setImageResource(R.drawable.ic_action_globus_light);
|
||||||
|
}
|
||||||
tv.setText(((TourInformation) it).getName());
|
tv.setText(((TourInformation) it).getName());
|
||||||
} else if(it instanceof StageInformation){
|
} else if(it instanceof StageInformation){
|
||||||
if(customization.getSelectedStage() == it) {
|
if(customization.getSelectedStage() == it) {
|
||||||
|
@ -281,12 +284,14 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDrawerIndicatorVisible(boolean b) {
|
private void setDrawerIndicatorVisible(boolean b) {
|
||||||
mDrawerToggle.setDrawerIndicatorEnabled(b);
|
if(mDrawerToggle.isDrawerIndicatorEnabled() != b) {
|
||||||
|
mDrawerToggle.setDrawerIndicatorEnabled(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void showSelectedItem() {
|
public void showSelectedItem() {
|
||||||
if(selectedItem == null) {
|
if(selectedItem != null) {
|
||||||
selectMenu(selectedItem);
|
selectMenu(selectedItem);
|
||||||
} else {
|
} else {
|
||||||
if(customization.getSelectedStage() != null) {
|
if(customization.getSelectedStage() != null) {
|
||||||
|
|
Loading…
Reference in a new issue