From 2d93b231979dc93b0d1c223ff93ee8c463f9fb06 Mon Sep 17 00:00:00 2001 From: "marcin.jedynski" Date: Sun, 6 Jan 2019 22:54:01 +0100 Subject: [PATCH] revered sharing tab UI disabling to wait for api response --- .idea/misc.xml | 2 +- .../findmytutor/activity/SharingFragment.java | 56 +++++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index dc44dda..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java index 5e900e7..1033d9e 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -123,7 +123,26 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere List predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList(); List predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList(); predefinedCoordsList.addAll(coords); - + if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { + preferenceCategory.removePreference(manualLocationList); + preferenceCategory.removePreference(removeManualLocation); + preferenceCategory.removePreference(manualLocationButton); + }else{ + if(predefinedCoordsList.isEmpty()){ + locationSharing.setEnabled(false); + locationSharing.setChecked(false); + PrefUtils.disableSharing(getApplicationContext()); + ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); + removeManualLocation.setEnabled(false); + manualLocationList.setEnabled(false); + manualLocationList.setSummary(""); + }else{ + manualLocationList.setEnabled(true); + manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); + removeManualLocation.setEnabled(true); + locationSharing.setEnabled(true); + } + } String[] stringnames = predefinedLocationsNames.toArray(new String[0]); predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames)); List activesId = Stream.of(coords).indexed() @@ -180,26 +199,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere statusMapping.put(0, "available"); statusMapping.put(1, "consultation"); statusMapping.put(2, "busy"); - if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { - preferenceCategory.removePreference(manualLocationList); - preferenceCategory.removePreference(removeManualLocation); - preferenceCategory.removePreference(manualLocationButton); - }else{ - if(predefinedCoordsList.isEmpty()){ - locationSharing.setEnabled(false); - locationSharing.setChecked(false); - PrefUtils.disableSharing(getApplicationContext()); - ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); - removeManualLocation.setEnabled(false); - manualLocationList.setEnabled(false); - manualLocationList.setSummary(""); - }else{ - manualLocationList.setEnabled(true); - manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); - removeManualLocation.setEnabled(true); - locationSharing.setEnabled(true); - } - } + statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); @@ -214,10 +214,18 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere /** Sharing level list **/ locationMode.setOnPreferenceChangeListener((preference, newValue) -> { - ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); - ((MapActivity) getActivity()).startBackgroundLocalizationTask(); + PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); + +// if(PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString()) && predefinedCoordsList.isEmpty()){ +/* Log.d("OTSOCHOZI","pyklo"); + }else{ + Log.d("OTSOCHOZI","niepyklo");*/ + + ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); + ((MapActivity) getActivity()).startBackgroundLocalizationTask(); +// } + - PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { if (!predefinedCoordsList.isEmpty()) { preferenceCategory.addPreference(manualLocationList);