Merge pull request #819 from Bars107/sherpafy

Updated back functionality.
This commit is contained in:
vshcherb 2014-08-06 17:14:12 +02:00
commit e6822fffcc
2 changed files with 26 additions and 17 deletions

View file

@ -42,7 +42,6 @@ public class SherpafyStageFragment extends SherlockFragment {
public SherpafyStageFragment() { public SherpafyStageFragment() {
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
@ -148,6 +147,10 @@ public class SherpafyStageFragment extends SherlockFragment {
} }
} }
public void onBackPressed() {
((TourViewActivity) getSherlockActivity()).selectMenu(tour);
}
/** /**
* This is a helper class that implements the management of tabs and all * This is a helper class that implements the management of tabs and all

View file

@ -3,6 +3,8 @@ package net.osmand.plus.sherpafy;
import java.util.List; import java.util.List;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import android.view.KeyEvent;
import android.widget.*;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
@ -30,12 +32,7 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
@ -50,6 +47,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
private static final int STATE_SELECT_TOUR = 1; private static final int STATE_SELECT_TOUR = 1;
private static final int STATE_TOUR_VIEW = 2; private static final int STATE_TOUR_VIEW = 2;
private static final int STATE_STAGE_OVERVIEW = 3; private static final int STATE_STAGE_OVERVIEW = 3;
private static final int STATE_DETAILED_OVERVIEW = 4;
private static int state = STATE_LOADING; private static int state = STATE_LOADING;
public static final int APP_EXIT_CODE = 4; public static final int APP_EXIT_CODE = 4;
@ -124,9 +122,17 @@ public class TourViewActivity extends SherlockFragmentActivity {
if (state == STATE_SELECT_TOUR) { if (state == STATE_SELECT_TOUR) {
super.onBackPressed(); super.onBackPressed();
} else if (state == STATE_TOUR_VIEW) { } else if (state == STATE_TOUR_VIEW) {
SherpafyHtmlFragment fragment = (SherpafyHtmlFragment) getSupportFragmentManager().findFragmentByTag(String.valueOf(STATE_DETAILED_OVERVIEW));
if (fragment != null && fragment.isVisible()) {
showSelectedItem();
} else {
selectMenu(R.string.sherpafy_tours); selectMenu(R.string.sherpafy_tours);
}
} else if (state == STATE_STAGE_OVERVIEW) { } else if (state == STATE_STAGE_OVERVIEW) {
selectMenu(customization.getSelectedTour()); SherpafyStageFragment fragment = (SherpafyStageFragment) getSupportFragmentManager().findFragmentByTag(String.valueOf(state));
if (fragment != null) {
fragment.onBackPressed();
}
} }
} }
@ -271,7 +277,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
setDrawerIndicatorVisible(false); setDrawerIndicatorVisible(false);
} }
if(fragment != null) { if(fragment != null) {
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment, String.valueOf(state)).commit();
} }
selectedItem = item; selectedItem = item;
if (mDrawerLayout.isDrawerOpen(mDrawerList)) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
@ -343,7 +349,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
bl.putString(SherpafyHtmlFragment.HTML, cont); bl.putString(SherpafyHtmlFragment.HTML, cont);
bl.putString(SherpafyHtmlFragment.TITLE, title); bl.putString(SherpafyHtmlFragment.TITLE, title);
fragment.setArguments(bl); fragment.setArguments(bl);
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment, String.valueOf(STATE_DETAILED_OVERVIEW)).commit();
} }