Merge pull request #819 from Bars107/sherpafy
Updated back functionality.
This commit is contained in:
commit
e6822fffcc
2 changed files with 26 additions and 17 deletions
|
@ -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,8 +147,12 @@ 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
|
||||||
* details of connecting a ViewPager with associated TabHost. It relies on a
|
* 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
|
* trick. Normally a tab host has a simple API for supplying a View or
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -121,12 +119,20 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
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) {
|
||||||
selectMenu(R.string.sherpafy_tours);
|
SherpafyHtmlFragment fragment = (SherpafyHtmlFragment) getSupportFragmentManager().findFragmentByTag(String.valueOf(STATE_DETAILED_OVERVIEW));
|
||||||
} else if (state == STATE_STAGE_OVERVIEW){
|
if (fragment != null && fragment.isVisible()) {
|
||||||
selectMenu(customization.getSelectedTour());
|
showSelectedItem();
|
||||||
|
} else {
|
||||||
|
selectMenu(R.string.sherpafy_tours);
|
||||||
|
}
|
||||||
|
} else if (state == STATE_STAGE_OVERVIEW) {
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue