Commit 29a1f103 authored by Fabius's avatar Fabius

FIX: #16 Springt zum in Settings gewählten Tab, wenn das Fragment resumend wird

parent 7ce7e5e1
...@@ -32,6 +32,8 @@ public class MensaFragment extends AbstractASiSTFragment { ...@@ -32,6 +32,8 @@ public class MensaFragment extends AbstractASiSTFragment {
private ViewPager viewPager; private ViewPager viewPager;
private ViewPagerAdapter adapter; private ViewPagerAdapter adapter;
private List<Canteen> canteens;
public MensaFragment() { public MensaFragment() {
// Required empty public constructor // Required empty public constructor
} }
...@@ -47,7 +49,7 @@ public class MensaFragment extends AbstractASiSTFragment { ...@@ -47,7 +49,7 @@ public class MensaFragment extends AbstractASiSTFragment {
adapter = new ViewPagerAdapter(getChildFragmentManager()); adapter = new ViewPagerAdapter(getChildFragmentManager());
//get Canteens //get Canteens
List<Canteen> canteens = CanteenDatabaseManager.getInstance().getAllCanteens(getActivity()); canteens = CanteenDatabaseManager.getInstance().getAllCanteens(getActivity());
if(canteens.size() == 0){ if(canteens.size() == 0){
if(canteens.size() == 0){ if(canteens.size() == 0){
Toast.makeText(getContext(),getText(R.string.module_canteen_noCanteen_found_toast),Toast.LENGTH_LONG).show(); Toast.makeText(getContext(),getText(R.string.module_canteen_noCanteen_found_toast),Toast.LENGTH_LONG).show();
...@@ -114,11 +116,7 @@ public class MensaFragment extends AbstractASiSTFragment { ...@@ -114,11 +116,7 @@ public class MensaFragment extends AbstractASiSTFragment {
int limit = (adapter.getCount() > 1 ? adapter.getCount() - 1 : 1); int limit = (adapter.getCount() > 1 ? adapter.getCount() - 1 : 1);
viewPager.setOffscreenPageLimit(limit); viewPager.setOffscreenPageLimit(limit);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
//TODO replace Key
String canteen = sharedPreferences.getString("canteens",null);
viewPager.setCurrentItem(getIndexItemLocation(canteen,canteens));
return view; return view;
} }
...@@ -147,4 +145,15 @@ public class MensaFragment extends AbstractASiSTFragment { ...@@ -147,4 +145,15 @@ public class MensaFragment extends AbstractASiSTFragment {
} }
return 0; return 0;
} }
@Override
public void onResume() {
super.onResume();
//Goes to in Preferences used Tab
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
//TODO replace Key
String canteen = sharedPreferences.getString("canteens",null);
viewPager.setCurrentItem(getIndexItemLocation(canteen,canteens));
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment