Fix retrofit rxjava
This commit is contained in:
parent
2b19229552
commit
6dbe50761a
@ -1,16 +1,10 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -26,22 +20,16 @@ import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
public class TutorTab extends AppCompatActivity {
|
||||
private TutorTabApi tutorTabService;
|
||||
private UserService userService;
|
||||
@ -53,6 +41,7 @@ public class TutorTab extends AppCompatActivity {
|
||||
private TextView userEmail;
|
||||
private TextView department;
|
||||
private Button saveButon;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -115,22 +104,30 @@ public class TutorTab extends AppCompatActivity {
|
||||
}));
|
||||
// setUpSaveListener();
|
||||
}
|
||||
/* private void setUpSaveListener(){
|
||||
|
||||
private void setUpSaveListener() {
|
||||
saveButon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
TutorTabViewModel newTab = new TutorTabViewModel();
|
||||
disposable.add(tutorTabService.apiUsersTutorTabByTutorIdPut(PrefUtils.getUserId(getApplicationContext()),newTab)
|
||||
putUserTab(newTab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void putUserTab(TutorTabViewModel tutorTabViewModel) {
|
||||
disposable.add(tutorTabService.apiUsersTutorTabByTutorIdPut(PrefUtils.getUserId(getApplicationContext()), tutorTabViewModel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
}
|
||||
});
|
||||
}*/
|
||||
private void handleResponse(Response<Void> resp) {
|
||||
|
||||
private void handleResponse(TutorTabViewModel tutorTabViewModel) {
|
||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.modal_feedback_thankyou), Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void handleError(Throwable error) {
|
||||
if (error instanceof HttpException) {
|
||||
|
||||
@ -144,6 +141,7 @@ public class TutorTab extends AppCompatActivity {
|
||||
Log.d("FEEDBACK", error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void showError(Throwable e) {
|
||||
String message;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public interface TutorTabApi {
|
||||
"Content-Type:application/json"
|
||||
})
|
||||
@PUT("api/users/tutorTab/{tutorId}")
|
||||
Observable<Void> apiUsersTutorTabByTutorIdPut(
|
||||
Observable<TutorTabViewModel> apiUsersTutorTabByTutorIdPut(
|
||||
@retrofit2.http.Path("tutorId") String tutorId, @retrofit2.http.Body TutorTabViewModel tutorTab
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user