Sherpafy redesign
This commit is contained in:
parent
ba8ce4db62
commit
d365dcd463
12 changed files with 388 additions and 493 deletions
|
@ -16,5 +16,5 @@
|
|||
android:choiceMode="singleChoice"
|
||||
android:divider="@drawable/divider"
|
||||
android:dividerHeight="1px"
|
||||
android:background="#b1b1b1"/>
|
||||
android:background="@color/color_white"/>
|
||||
</android.support.v4.widget.DrawerLayout>
|
|
@ -2,38 +2,22 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" android:background="@color/color_white"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp" >
|
||||
|
||||
<FrameLayout >
|
||||
<ImageView
|
||||
android:id="@+id/TourImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:id="@+id/Icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TourName"
|
||||
android:id="@+id/Text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:background="@color/shadow_color"
|
||||
android:ellipsize="end"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/color_white"
|
||||
/>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/TourDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="3"
|
||||
android:ellipsize="end"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="1"/>
|
||||
android:maxLines="1" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,53 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#eeeeee" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#ffffff"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:background="#fafafa"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/shadow_color" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/TourImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/shadow_color"
|
||||
android:gravity="bottom"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="7dp"
|
||||
android:paddingTop="5dp" >
|
||||
android:scaleType="centerCrop"
|
||||
>
|
||||
</ImageView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TourName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/shadow_color"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="bottom"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="24sp" />
|
||||
</LinearLayout>
|
||||
android:textSize="20sp" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TourDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textSize="18sp" />
|
||||
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_tour"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/select_tour" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/access_code"
|
||||
android:src="@drawable/ic_action_settings_light"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,74 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="17dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/collapse"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:button="@drawable/expandable_category"
|
||||
android:checked="true"
|
||||
android:textOff=""
|
||||
android:textOn=""
|
||||
android:textSize="21sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/stages"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:orientation="vertical" >
|
||||
</RadioGroup>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tour_description"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="18sp" >
|
||||
</TextView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tour_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="4dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tour_fulldescription"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:orientation="vertical" >
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -64,5 +64,5 @@
|
|||
<color name="osmbug_not_submitted">#C8FFFF00</color> <!-- standard YELLOW -->
|
||||
|
||||
<color name="distance_color">#dd6CB336</color>
|
||||
<color name="shadow_color">#33aaaaaa</color>
|
||||
<color name="shadow_color">#33888888</color>
|
||||
</resources>
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="sherpafy_more_information">More information</string>
|
||||
<string name="sherpafy_continue_stage">Continue</string>
|
||||
<string name="sherpafy_start_stage">Start</string>
|
||||
<string name="sherpafy_download_tours">Download Tours</string>
|
||||
<string name="sherpafy_tours">Sherpafy Tours</string>
|
||||
<string name="access_code_is_not_valid">Access code is not valid</string>
|
||||
<string name="enter_access_code">Enter access code</string>
|
||||
|
|
|
@ -143,6 +143,11 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
indexFileNames.put(tr.getName(), date);
|
||||
final TourInformation tourInformation = new TourInformation(tr);
|
||||
tourPresent.add(tourInformation);
|
||||
try {
|
||||
tourInformation.loadFullInformation();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (selected) {
|
||||
reloadSelectedTour(progress, tr, tourInformation, warns);
|
||||
}
|
||||
|
|
|
@ -13,12 +13,13 @@ public class SherpafyLoadingFragment extends SherlockFragment {
|
|||
OsmandApplication app;
|
||||
private View view;
|
||||
|
||||
public SherpafyLoadingFragment(OsmandApplication app) {
|
||||
this.app = app;
|
||||
public SherpafyLoadingFragment() {
|
||||
}
|
||||
|
||||
|
||||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
view = inflater.inflate(R.layout.sherpafy_loading, container, false);
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,212 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.Html.ImageGetter;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
|
||||
|
||||
public class SherpafyTourOverviewFragment extends SherlockListFragment {
|
||||
private static final int ACTION_DOWNLOAD = 5;
|
||||
OsmandApplication app;
|
||||
private View view;
|
||||
private SherpafyCustomization customization;
|
||||
private TourInformation item;
|
||||
|
||||
public SherpafyTourOverviewFragment() {
|
||||
}
|
||||
|
||||
public void setTour(TourInformation item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
customization = (SherpafyCustomization) app.getAppCustomization();
|
||||
TourAdapter tourAdapter = new TourAdapter(customization.getTourInformations());
|
||||
setListAdapter(tourAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Toast.makeText(getActivity(), getListAdapter().getItem(position).toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
//createMenuItem(menu, ACTION_SETTINGS_ID, R.string.settings, R.drawable.ic_action_settings_light,
|
||||
// R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
// | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
|
||||
// com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, ACTION_DOWNLOAD, 0, R.string.sherpafy_download_tours).setShowAsActionFlags(
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
//// OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
//// boolean light = true; //app.getSettings().isLightActionBar();
|
||||
// //menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
||||
// menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
// @Override
|
||||
// public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
getListView().setBackgroundColor(0x00eeeeee);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TourAdapter extends ArrayAdapter<TourInformation> {
|
||||
|
||||
public TourAdapter(List<TourInformation> list) {
|
||||
super(getActivity(), R.layout.sherpafy_list_tour_item, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.sherpafy_list_tour_item, parent, false);
|
||||
}
|
||||
TourInformation ti = getItem(position);
|
||||
TextView description = (TextView) row.findViewById(R.id.TourDescription);
|
||||
TextView name = (TextView) row.findViewById(R.id.TourName);
|
||||
description.setText(ti.getShortDescription());
|
||||
name.setText(ti.getName());
|
||||
ImageView iv = (ImageView) row.findViewById(R.id.TourImage);
|
||||
if(ti.getImageBitmap() != null) {
|
||||
iv.setImageBitmap(ti.getImageBitmap());
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ImageGetter getImageGetter(final View v) {
|
||||
return new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String s) {
|
||||
Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s);
|
||||
v.setTag(file);
|
||||
Drawable bmp = new BitmapDrawable(getResources(), file);
|
||||
// if image is thicker than screen - it may cause some problems, so we need to scale it
|
||||
int imagewidth = bmp.getIntrinsicWidth();
|
||||
// TODO
|
||||
// if (displaySize.x - 1 > imagewidth) {
|
||||
// bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
|
||||
// } else {
|
||||
// double scale = (double) (displaySize.x - 1) / imagewidth;
|
||||
// bmp.setBounds(0, 0, (int) (scale * bmp.getIntrinsicWidth()),
|
||||
// (int) (scale * bmp.getIntrinsicHeight()));
|
||||
// }
|
||||
return bmp;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addOnClickListener(final TextView tv) {
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getTag() instanceof Bitmap) {
|
||||
final AccessibleAlertBuilder dlg = new AccessibleAlertBuilder(getActivity());
|
||||
dlg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
ScrollView sv = new ScrollView(getActivity());
|
||||
ImageView img = new ImageView(getActivity());
|
||||
img.setImageBitmap((Bitmap) tv.getTag());
|
||||
sv.addView(img);
|
||||
dlg.setView(sv);
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void prepareBitmap(Bitmap imageBitmap) {
|
||||
ImageView img = null;
|
||||
if (imageBitmap != null) {
|
||||
img.setImageBitmap(imageBitmap);
|
||||
img.setAdjustViewBounds(true);
|
||||
img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
img.setCropToPadding(true);
|
||||
img.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void goToMap() {
|
||||
if (customization.getSelectedStage() != null) {
|
||||
GPXFile gpx = customization.getSelectedStage().getGpx();
|
||||
List<SelectedGpxFile> sgpx = getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
if (gpx == null && sgpx.size() > 0) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
} else if (sgpx.size() != 1 || sgpx.get(0).getGpxFile() != gpx) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
if (gpx != null && gpx.findPointToShow() != null) {
|
||||
WptPt p = gpx.findPointToShow();
|
||||
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent newIntent = new Intent(getActivity(), customization.getMapActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
this.startActivityForResult(newIntent, 0);
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
}
|
|
@ -12,8 +12,8 @@ import android.app.AlertDialog.Builder;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -39,28 +39,29 @@ public class SherpafyToursFragment extends SherlockListFragment {
|
|||
private View view;
|
||||
private SherpafyCustomization custom;
|
||||
|
||||
public SherpafyToursFragment(OsmandApplication app) {
|
||||
this.app = app;
|
||||
public SherpafyToursFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
OsmandApplication app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
custom = (SherpafyCustomization) app.getAppCustomization();
|
||||
TourAdapter tourAdapter = new TourAdapter(custom.getTourInformations());
|
||||
setListAdapter(tourAdapter);
|
||||
getListView().setBackgroundColor(0x00eeeeee);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Toast.makeText(getActivity(), getListAdapter().getItem(position).toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
|
||||
com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, ACTION_DOWNLOAD, 0, R.string.download_tours).setShowAsActionFlags(
|
||||
com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, ACTION_DOWNLOAD, 0, R.string.sherpafy_download_tours).setShowAsActionFlags(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
// OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
// boolean light = true; //app.getSettings().isLightActionBar();
|
||||
|
@ -76,7 +77,11 @@ public class SherpafyToursFragment extends SherlockListFragment {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
getListView().setBackgroundColor(0x00eeeeee);
|
||||
}
|
||||
|
||||
protected void openAccessCode(final boolean startDownload) {
|
||||
|
@ -149,7 +154,7 @@ public class SherpafyToursFragment extends SherlockListFragment {
|
|||
class TourAdapter extends ArrayAdapter<TourInformation> {
|
||||
|
||||
public TourAdapter(List<TourInformation> list) {
|
||||
super(getActivity(), R.layout.search_history_list_item, list);
|
||||
super(getActivity(), R.layout.sherpafy_list_tour_item, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,7 +171,7 @@ public class SherpafyToursFragment extends SherlockListFragment {
|
|||
name.setText(ti.getName());
|
||||
ImageView iv = (ImageView) row.findViewById(R.id.TourImage);
|
||||
if(ti.getImageBitmap() != null) {
|
||||
iv.setBackground(new BitmapDrawable(getResources(), ti.getImageBitmap()));
|
||||
iv.setImageBitmap(ti.getImageBitmap());
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
|
|
@ -1,50 +1,25 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.text.Html;
|
||||
import android.text.Html.ImageGetter;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
|
@ -55,27 +30,16 @@ import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
|
|||
*/
|
||||
public class TourViewActivity extends SherlockFragmentActivity {
|
||||
|
||||
private static final int ACTION_GO_TO_MAP = 1;
|
||||
private static final int ACTION_TOUR_ID = 3;
|
||||
private static final int ACTION_SHARE = 4;
|
||||
|
||||
private static final int STATE_LOADING = -1;
|
||||
private static final int STATE_TOUR_VIEW = 1;
|
||||
private static final int STATE_SELECT_TOUR = 2;
|
||||
private static final int STATE_SELECT_TOUR = 1;
|
||||
private static final int STATE_TOUR_VIEW = 2;
|
||||
private static final int STATE_STAGE_OVERVIEW = 3;
|
||||
private static int state = STATE_LOADING;
|
||||
|
||||
|
||||
public static final int APP_EXIT_CODE = 4;
|
||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||
|
||||
|
||||
ImageView img;
|
||||
TextView description;
|
||||
LinearLayout fullDescriptionView;
|
||||
RadioGroup stages;
|
||||
private ToggleButton collapser;
|
||||
private Set<TourInformation> currentTourInformations = new HashSet<TourInformation>();
|
||||
|
||||
private SherpafyCustomization customization;
|
||||
private Point displaySize;
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
|
@ -83,6 +47,8 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
private ListView mDrawerList;
|
||||
private ArrayAdapter<Object> drawerAdapter;
|
||||
private SherpafyToursFragment toursFragment;
|
||||
private Object selectedItem;
|
||||
private SherpafyTourOverviewFragment tourOverview;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -116,12 +82,57 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
mDrawerLayout.setDrawerTitle(GravityCompat.START, getString(R.string.sherpafy_app_name));
|
||||
|
||||
// Set the adapter for the list view
|
||||
drawerAdapter = new ArrayAdapter<Object>(this, android.R.layout.simple_list_item_1){
|
||||
drawerAdapter = setupAdapter();
|
||||
mDrawerList.setAdapter(drawerAdapter);
|
||||
// Set the list's click listener
|
||||
mDrawerList.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectMenu(position, drawerAdapter.getItem(position));
|
||||
}
|
||||
});
|
||||
|
||||
displaySize = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment())
|
||||
.commit();
|
||||
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
||||
R.string.default_buttons_other_actions, R.string.close);
|
||||
}
|
||||
|
||||
|
||||
private ArrayAdapter<Object> setupAdapter() {
|
||||
return new ArrayAdapter<Object>(this, R.layout.sherpafy_drawer_list_item){
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Object it = getItem(position);
|
||||
if(convertView == null){
|
||||
convertView = getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
|
||||
convertView = getLayoutInflater().inflate(R.layout.sherpafy_drawer_list_item, null);
|
||||
}
|
||||
final ImageView imView = (ImageView) convertView.findViewById(R.id.Icon);
|
||||
TextView tv = (TextView) convertView.findViewById(R.id.Text);
|
||||
if(it.equals(R.string.sherpafy_tours)) {
|
||||
imView.
|
||||
setImageResource(R.drawable.icon_sherpafy);
|
||||
tv.setText(getString(R.string.sherpafy_tours));
|
||||
} else if(it instanceof TourInformation){
|
||||
imView.setImageResource(R.drawable.ic_action_globus_light);
|
||||
tv.setText(((TourInformation) it).getName());
|
||||
} else if(it instanceof StageInformation){
|
||||
if(customization.getSelectedStage() == it) {
|
||||
imView.setImageResource(R.drawable.ic_action_gplay_over_light);
|
||||
} else if(selectedItem == it) {
|
||||
imView.setImageResource(R.drawable.ic_action_ok_light);
|
||||
} else {
|
||||
imView.setImageDrawable(null);
|
||||
}
|
||||
tv.setText(((StageInformation) it).getName());
|
||||
} else {
|
||||
imView.setImageDrawable(null);
|
||||
tv.setText(it.toString());
|
||||
}
|
||||
if(position == 0) {
|
||||
((TextView) convertView).setText(R.string.sherpafy_tours);
|
||||
|
@ -131,38 +142,8 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
return convertView;
|
||||
}
|
||||
};
|
||||
mDrawerList.setAdapter(drawerAdapter);
|
||||
// Set the list's click listener
|
||||
mDrawerList.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectMenu(position, drawerAdapter.getItem(position));
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
}
|
||||
});
|
||||
|
||||
displaySize = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment(getMyApplication()))
|
||||
.commit();
|
||||
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
||||
R.string.default_buttons_other_actions, R.string.close);
|
||||
}
|
||||
|
||||
protected void selectMenu(int position, Object item) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (position == 0) {
|
||||
if (toursFragment == null) {
|
||||
toursFragment = new SherpafyToursFragment(getMyApplication());
|
||||
}
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, toursFragment).commit();
|
||||
state = STATE_SELECT_TOUR;
|
||||
}
|
||||
updateActionBarTitle();
|
||||
}
|
||||
|
||||
public void updateActionBarTitle() {
|
||||
if(state == STATE_LOADING) {
|
||||
|
@ -176,14 +157,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
|
||||
|
||||
public void loadingFinished() {
|
||||
drawerAdapter.clear();
|
||||
drawerAdapter.add(getString(R.string.sherpafy_tours));
|
||||
if(customization.getSelectedTour() != null) {
|
||||
drawerAdapter.add(customization.getSelectedTour());
|
||||
if(customization.getSelectedStage() != null) {
|
||||
drawerAdapter.add(customization.getSelectedStage());
|
||||
}
|
||||
}
|
||||
selectMenu(0, getString(R.string.sherpafy_tours));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,29 +173,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
private ImageGetter getImageGetter(final View v) {
|
||||
return new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String s) {
|
||||
Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s);
|
||||
v.setTag(file);
|
||||
Drawable bmp = new BitmapDrawable(getResources(), file);
|
||||
// if image is thicker than screen - it may cause some problems, so we need to scale it
|
||||
int imagewidth = bmp.getIntrinsicWidth();
|
||||
if (displaySize.x - 1 > imagewidth) {
|
||||
bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
|
||||
} else {
|
||||
double scale = (double) (displaySize.x - 1) / imagewidth;
|
||||
bmp.setBounds(0, 0, (int) (scale * bmp.getIntrinsicWidth()),
|
||||
(int) (scale * bmp.getIntrinsicHeight()));
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
@ -235,130 +186,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
private void setTourInfoContent() {
|
||||
setContentView(R.layout.sherpafy_tour_info);
|
||||
|
||||
collapser = (ToggleButton) findViewById(R.id.collapse);
|
||||
stages = (RadioGroup) findViewById(R.id.stages);
|
||||
stages.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
||||
if (i == 0) {
|
||||
customization.selectStage(null, IProgress.EMPTY_PROGRESS);
|
||||
} else {
|
||||
final StageInformation st = customization.getSelectedTour().getStageInformation().get(i - 1);
|
||||
customization.selectStage(st, IProgress.EMPTY_PROGRESS);
|
||||
}
|
||||
updateTourContentView();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
collapser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
stages.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
stages.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTourContentView() {
|
||||
if (customization.getSelectedStage() == null) {
|
||||
if (customization.getSelectedTour() != null) {
|
||||
TourInformation curTour = customization.getSelectedTour();
|
||||
description.setText(Html.fromHtml(curTour.getShortDescription(), getImageGetter(description), null));
|
||||
setFullDescriptions(curTour.getFulldescription());
|
||||
// ((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(Html.fromHtml(st.getShortDescription(), getImageGetter(description), null));
|
||||
setFullDescriptions(st.getFullDescription());
|
||||
|
||||
// ((TextView)findViewById(R.id.tour_name)).setText(st.getName());
|
||||
setCollapserText(st.getName());
|
||||
prepareBitmap(st.getImageBitmap());
|
||||
}
|
||||
}
|
||||
|
||||
private void setFullDescriptions(String fulldescription) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (fulldescription.length() > 0) {
|
||||
int i = 0;
|
||||
while ((i = fulldescription.indexOf("<img", 1)) != -1) {
|
||||
list.add(fulldescription.substring(0, i));
|
||||
fulldescription = fulldescription.substring(i);
|
||||
}
|
||||
}
|
||||
list.add(fulldescription);
|
||||
fullDescriptionView.removeAllViews();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final TextView tv = new TextView(this);
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||
tv.setPadding(0, 3, 0, 3);
|
||||
tv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
addOnClickListener(tv);
|
||||
tv.setText(Html.fromHtml(list.get(i), getImageGetter(tv), null));
|
||||
fullDescriptionView.addView(tv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addOnClickListener(final TextView tv) {
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getTag() instanceof Bitmap) {
|
||||
final AccessibleAlertBuilder dlg = new AccessibleAlertBuilder(getActivity());
|
||||
dlg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
ScrollView sv = new ScrollView(getActivity());
|
||||
ImageView img = new ImageView(getActivity());
|
||||
img.setImageBitmap((Bitmap) tv.getTag());
|
||||
sv.addView(img);
|
||||
dlg.setView(sv);
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setCollapserText(String t) {
|
||||
collapser.setText(" " + t);
|
||||
collapser.setTextOff(" " + t);
|
||||
collapser.setTextOn(" " + t);
|
||||
}
|
||||
|
||||
|
||||
private void startTourView() {
|
||||
if (state != STATE_TOUR_VIEW) {
|
||||
setTourInfoContent();
|
||||
state = STATE_TOUR_VIEW;
|
||||
}
|
||||
getSupportActionBar().setTitle(customization.getSelectedTour().getName());
|
||||
updateTourView();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
|
||||
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
// createMenuItem(menu, ACTION_SETTINGS_ID, R.string.settings, R.drawable.ic_action_settings_light,
|
||||
// R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
// | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) {
|
||||
// int r = getMyApplication().getSettings().isLightActionBar() ? iconLight : iconDark;
|
||||
int r = iconLight;
|
||||
|
@ -375,84 +202,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
return menuItem;
|
||||
}
|
||||
|
||||
private void updateTourView() {
|
||||
TourInformation curTour = customization.getSelectedTour();
|
||||
List<StageInformation> stagesInfo = curTour.getStageInformation();
|
||||
|
||||
img = (ImageView) findViewById(R.id.tour_image);
|
||||
description = (TextView) findViewById(R.id.tour_description);
|
||||
description.setVisibility(View.VISIBLE);
|
||||
addOnClickListener(description);
|
||||
fullDescriptionView = (LinearLayout) findViewById(R.id.tour_fulldescription);
|
||||
fullDescriptionView.setVisibility(View.VISIBLE);
|
||||
|
||||
// in case of reloading view - remove all previous radio buttons
|
||||
stages.removeAllViews();
|
||||
|
||||
// get count of radio buttons
|
||||
final int count = stagesInfo.size() + 1;
|
||||
final RadioButton[] rb = new RadioButton[count];
|
||||
|
||||
rb[0] = new RadioButton(this);
|
||||
rb[0].setId(0);
|
||||
stages.addView(rb[0]);
|
||||
rb[0].setText(getString(R.string.overview));
|
||||
// add radio buttons to view
|
||||
for (int i = 1; i < count; i++) {
|
||||
rb[i] = new RadioButton(this);
|
||||
rb[i].setId(i);
|
||||
stages.addView(rb[i]);
|
||||
rb[i].setText(stagesInfo.get(i - 1).getName());
|
||||
}
|
||||
|
||||
StageInformation stage = customization.getSelectedStage();
|
||||
|
||||
int i = 0;
|
||||
if (stage != null) {
|
||||
for (i = 1; i < count; i++) {
|
||||
if (stage == stagesInfo.get(i - 1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i != count) {
|
||||
stages.check(i);
|
||||
} else {
|
||||
stages.check(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void goToMap() {
|
||||
if (customization.getSelectedStage() != null) {
|
||||
GPXFile gpx = customization.getSelectedStage().getGpx();
|
||||
List<SelectedGpxFile> sgpx = getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
if (gpx == null && sgpx.size() > 0) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
} else if (sgpx.size() != 1 || sgpx.get(0).getGpxFile() != gpx) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
if (gpx != null && gpx.findPointToShow() != null) {
|
||||
WptPt p = gpx.findPointToShow();
|
||||
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent newIntent = new Intent(this, customization.getMapActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
this.startActivityForResult(newIntent, 0);
|
||||
}
|
||||
|
||||
private void prepareBitmap(Bitmap imageBitmap) {
|
||||
if (imageBitmap != null) {
|
||||
img.setImageBitmap(imageBitmap);
|
||||
img.setAdjustViewBounds(true);
|
||||
img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
img.setCropToPadding(true);
|
||||
img.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
@ -465,20 +214,53 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
mDrawerLayout.openDrawer(mDrawerList);
|
||||
}
|
||||
return true;
|
||||
} else if (item.getItemId() == ACTION_GO_TO_MAP) {
|
||||
goToMap();
|
||||
return true;
|
||||
} else if (item.getItemId() == ACTION_TOUR_ID) {
|
||||
startTourView();
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
// return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void selectMenu(int position, Object item) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (position == 0) {
|
||||
if (toursFragment == null) {
|
||||
toursFragment = new SherpafyToursFragment();
|
||||
}
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, toursFragment).commit();
|
||||
state = STATE_SELECT_TOUR;
|
||||
} else if(item instanceof TourInformation) {
|
||||
state = STATE_TOUR_VIEW;
|
||||
if(tourOverview == null) {
|
||||
tourOverview = new SherpafyTourOverviewFragment();
|
||||
}
|
||||
tourOverview.setTour((TourInformation)item);
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, toursFragment).commit();
|
||||
} else if(item instanceof StageInformation) {
|
||||
state = STATE_STAGE_OVERVIEW;
|
||||
}
|
||||
selectedItem = item;
|
||||
if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
}
|
||||
drawerAdapter.clear();
|
||||
drawerAdapter.add(R.string.sherpafy_tours);
|
||||
TourInformation selectedTour = customization.getSelectedTour();
|
||||
for(TourInformation it : customization.getTourInformations()) {
|
||||
int insert = drawerAdapter.getCount();
|
||||
if(it == selectedTour) {
|
||||
insert = 1;
|
||||
}
|
||||
drawerAdapter.insert(it, insert++);
|
||||
if(it == selectedItem) {
|
||||
for(StageInformation st : it.getStageInformation()) {
|
||||
drawerAdapter.insert(st, insert++);
|
||||
}
|
||||
} else if(it == selectedTour) {
|
||||
StageInformation st = customization.getSelectedStage();
|
||||
if(st != null) {
|
||||
drawerAdapter.insert(st, insert++);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateActionBarTitle();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue