From 930876a2f54cfe88a46a7a42dc2890b70701a1c2 Mon Sep 17 00:00:00 2001 From: "marcin.jedynski" Date: Mon, 10 Dec 2018 01:16:18 +0100 Subject: [PATCH] sharing tab stable release --- .../findmytutor/activity/LoginActivity.java | 5 +- .../findmytutor/activity/SharingFragment.java | 46 +++++++++++-------- app/src/main/res/values/strings.xml | 1 + 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java index 1f144be..91cf913 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java @@ -149,10 +149,9 @@ public class LoginActivity extends AppCompatActivity { private void loginProcess(String email, String password) { ValidateUser user = new ValidateUser(email, password); - LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email); +// LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email); // disposable.add(ldapService.fakeValidate(fakeUser) -// disposable.add(ldapService.validate(user) - disposable.add(ldapService.fakeValidate(fakeUser) + disposable.add(ldapService.validate(user) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)); 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 1257833..494581f 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 @@ -98,11 +98,12 @@ public class SharingFragment extends PreferenceFragment { else{ setListPreferenceData(manualLocationList.getKey(), stringnames,null); } + Log.d("sharingpref", names.toString()); } @Override public void onError(Throwable e) { - Toast.makeText(getApplicationContext(), R.string.manual_status_error, Toast.LENGTH_SHORT).show(); + Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show(); } })); @@ -123,14 +124,7 @@ public class SharingFragment extends PreferenceFragment { statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class); disposable = new CompositeDisposable(); getStatuses(disposable); - - if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { - getLocations(disposable); - } - Log.d("SHAR TAB", (String) statusList.getSummary()); - Log.d("SHAR TAB",( String) manualLocationList.getSummary()); -// Log.d("SHAR TAB","dupa"); - + getLocations(disposable); locationLevelMapping = new HashMap(); locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); @@ -160,7 +154,6 @@ public class SharingFragment extends PreferenceFragment { if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { if(!predefinedCoordsList.isEmpty()){ preferenceCategory.addPreference(manualLocationList); - getLocations(disposable); } preferenceCategory.addPreference(manualLocationButton); @@ -176,6 +169,12 @@ public class SharingFragment extends PreferenceFragment { if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { preferenceCategory.removePreference(manualLocationList); preferenceCategory.removePreference(manualLocationButton); + }else{ +// if(predefinedCoordsList.isEmpty()){ +//// preferenceCategory.removePreference(manualLocationList); +// +// +// } } /** Custom manual location list change listener **/ @@ -219,6 +218,7 @@ public class SharingFragment extends PreferenceFragment { return true; }); + } @Override @@ -230,19 +230,25 @@ public class SharingFragment extends PreferenceFragment { } protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) { - ListPreference lp = (ListPreference) findPreference(lp_name); - lp.setEntries(entries); - CharSequence[] entryValues = new CharSequence[entries.length]; + try { + ListPreference lp = (ListPreference) findPreference(lp_name); + lp.setEntries(entries); + CharSequence[] entryValues = new CharSequence[entries.length]; - for (int i = 0; i < entries.length; i++) { - entryValues[i] = Integer.toString(i); - } + for (int i = 0; i < entries.length; i++) { + entryValues[i] = Integer.toString(i); + } - lp.setDefaultValue(0); - lp.setEntryValues(entryValues); + lp.setDefaultValue(0); + lp.setEntryValues(entryValues); + + if(entries.length > 0 && activeId != null) + lp.setValueIndex(activeId); + }catch (Exception e){ +// Toast.makeText(getApplicationContext(), +// "duupa", Toast.LENGTH_SHORT).show(); + } - if(entries.length > 0 && activeId != null) - lp.setValueIndex(activeId); }; private void handleResponse(List resp) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 70b2d71..f848cbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -233,6 +233,7 @@ Network Error! Error handling status fetch Error handling status fetch + Error handling status fetch Auto reporting on issue is OFF Auto reporting on issue is ON -- 2.20.1