Merge branch 'fix-bugs-related-to-network' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
331e7b5fe3
@ -86,6 +86,7 @@ public class BlackList extends AppCompatActivity {
|
||||
Switch aSwitch;
|
||||
@BindView(R.id.add_to_black_list_fab)
|
||||
FloatingActionButton addToBlackListFab;
|
||||
|
||||
private Integer prevSize;
|
||||
private BlackListAdapter mAdapter;
|
||||
private List<User> blacklistedUsers = new ArrayList<>();
|
||||
@ -283,27 +284,6 @@ public class BlackList extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
@ -358,4 +338,25 @@ public class BlackList extends AppCompatActivity {
|
||||
},this::showError)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
|
||||
import org.apache.commons.collections4.BidiMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -59,9 +57,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
protected RightButtonPreference removeManualStatus;
|
||||
protected Preference manualStatus;
|
||||
protected ListPreference statusList;
|
||||
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
|
||||
private HashMap<String, String> locationMap;
|
||||
private ArrayList<String> locationUUIDs;
|
||||
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
|
||||
private HashMap<Integer, String> locationLevelMapping;
|
||||
private HashMap<Integer, String> statusMapping;
|
||||
private PredefinedStatusesService statusesService;
|
||||
@ -114,8 +112,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||
locationMap = new HashMap<String, String>();
|
||||
locationUUIDs = new ArrayList<String>();
|
||||
for (PredefinedCoordViewModel i : coords) locationMap.put(i.getPredefinedCoordinateId(),i.getName());
|
||||
for (PredefinedCoordViewModel i : coords) locationUUIDs.add(i.getPredefinedCoordinateId());
|
||||
for (PredefinedCoordViewModel i : coords)
|
||||
locationMap.put(i.getPredefinedCoordinateId(), i.getName());
|
||||
for (PredefinedCoordViewModel i : coords)
|
||||
locationUUIDs.add(i.getPredefinedCoordinateId());
|
||||
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
|
||||
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
|
||||
predefinedCoordsList.addAll(coords);
|
||||
@ -149,8 +149,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
if (activesId.size() == 0) {
|
||||
setListPreferenceData(manualLocationList, stringnames, null);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
|
||||
}
|
||||
|
||||
@ -240,6 +239,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
/** Custom manual location list change listener **/
|
||||
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
||||
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
CharSequence[] entries = lp.getEntries();
|
||||
PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0);
|
||||
@ -260,7 +261,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
});
|
||||
|
||||
|
||||
|
||||
/** Button 'choose from map' button listener **/
|
||||
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
@ -300,6 +300,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
public void showRemoveDialog(CharSequence[] entries, String service) {
|
||||
boolean[] checked = new boolean[entries.length];
|
||||
ArrayList<String> tobeDeleted = new ArrayList<String>();
|
||||
@ -413,6 +414,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteStatuses(List<String> resp) {
|
||||
if (resp.isEmpty()) {
|
||||
disableStatusPreferences();
|
||||
@ -429,14 +431,14 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp) {
|
||||
getLocations(disposable);
|
||||
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||
if (resp.isEmpty()) {
|
||||
disableManualLocationPreferences();
|
||||
} else {
|
||||
if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
|
||||
{
|
||||
if (!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) {
|
||||
for (PredefinedCoordViewModel location : resp) {
|
||||
if (location.getName().equals(currentEntry)) {
|
||||
manualLocationList.setValueIndex(resp.indexOf(location));
|
||||
@ -451,6 +453,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void disableStatusPreferences() {
|
||||
removeManualStatus.setEnabled(false);
|
||||
statusList.setEnabled(false);
|
||||
@ -459,12 +462,14 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
PrefUtils.disableStatus(getApplicationContext());
|
||||
|
||||
}
|
||||
|
||||
private void enableStatusPreferences() {
|
||||
removeManualStatus.setEnabled(true);
|
||||
statusList.setEnabled(true);
|
||||
statusSwitch.setEnabled(true);
|
||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
||||
}
|
||||
|
||||
private void disableManualLocationPreferences() {
|
||||
removeManualLocation.setEnabled(false);
|
||||
manualLocationList.setEnabled(false);
|
||||
@ -475,6 +480,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
||||
|
||||
}
|
||||
|
||||
private void enableManualLocationPreferences() {
|
||||
removeManualLocation.setEnabled(true);
|
||||
manualLocationList.setEnabled(true);
|
||||
@ -499,4 +505,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,12 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
int code = ((HttpException) e).response().code();
|
||||
int code = 0;
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
code = ((HttpException) e).response().code();
|
||||
}
|
||||
|
||||
if( code == 404){
|
||||
ifTutorTabExists = false;
|
||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),new ArrayList<DutyHourViewModel>());
|
||||
|
@ -56,12 +56,9 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableObserver;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
|
||||
|
||||
public class WhiteList extends AppCompatActivity {
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
@ -77,12 +74,12 @@ public class WhiteList extends AppCompatActivity {
|
||||
Switch aSwitch;
|
||||
@BindView(R.id.add_to_white_list_fab)
|
||||
FloatingActionButton addToWhiteListFab;
|
||||
|
||||
private WhiteListAdapter mAdapter;
|
||||
private Integer prevSize;
|
||||
private List<User> whitelistedUsers = new ArrayList<>();
|
||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -228,8 +225,9 @@ public class WhiteList extends AppCompatActivity {
|
||||
|
||||
private void sendUserToWhitelist(String body) {
|
||||
StudentIdModel studentIdModel = new StudentIdModel(body);
|
||||
|
||||
disposable.add(
|
||||
userService.addStudentToWhitelist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
|
||||
userService.addStudentToWhitelist(tutorId, studentIdModel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleAddUser,this::showError)
|
||||
@ -269,32 +267,6 @@ public class WhiteList extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_white_list, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
@ -343,4 +315,31 @@ public class WhiteList extends AppCompatActivity {
|
||||
},this::showError)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_white_list, menu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,6 @@ public class WrapContentLinearLayoutManager extends LinearLayoutManager {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||
super(context, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
try {
|
||||
|
@ -27,6 +27,8 @@
|
||||
android:defaultValue="0"
|
||||
android:key="key_manual_location_value"
|
||||
android:summary="%s"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:title="@string/title_list_manual_location" />
|
||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||
android:key="manual_location_button"
|
||||
@ -47,9 +49,11 @@
|
||||
android:persistent="true"
|
||||
android:title="@string/status_switch_title"/>
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:defaultValue="0"
|
||||
android:key="@string/key_status_value"
|
||||
android:summary="%s"
|
||||
android:entries="@array/status_entries"
|
||||
android:entryValues="@array/status_values"
|
||||
android:title="@string/status_list_title" />
|
||||
<EditTextPreference
|
||||
android:key="key_manual_status"
|
||||
|
@ -55,26 +55,17 @@
|
||||
</string-array>
|
||||
<string-array name="status_entries">
|
||||
<item>@string/description_available</item>
|
||||
<item>@string/description_busy</item>
|
||||
<item>@string/description_consultation</item>
|
||||
</string-array>
|
||||
<string-array name="status_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string-array name="manual_location_entries">
|
||||
<item>@string/assembly_c</item>
|
||||
<item>@string/assembly_a</item>
|
||||
<item>@string/passage_d</item>
|
||||
</string-array>
|
||||
<string-array name="manual_location_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string-array name="language_entries">
|
||||
|
||||
<item>@string/lang_eng</item>
|
||||
<item>@string/lang_pol</item>
|
||||
</string-array>
|
||||
|
Loading…
Reference in New Issue
Block a user