Fix login
This commit is contained in:
parent
5b2dfff4dd
commit
c97f892eab
Binary file not shown.
@ -36,5 +36,5 @@ dependencies {
|
||||
implementation "io.swagger:swagger-annotations:1.5.15"
|
||||
implementation "org.threeten:threetenbp:1.3.5"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:3.10.0"
|
||||
|
||||
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.4.0'
|
||||
}
|
||||
|
@ -7,6 +7,9 @@
|
||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -37,7 +37,6 @@ import com.uam.wmi.findmytutor.model.LdapUser;
|
||||
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
|
||||
import com.uam.wmi.findmytutor.service.LdapService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -321,10 +320,13 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
LdapService service = RetrofitClientInstance.createService(LdapService.class);
|
||||
|
||||
LdapUser user = new LdapUser("string",mPassword,"string","pracownik","string","string",mEmail);
|
||||
LdapUser user = new LdapUser("string",mPassword,"string","string","string","string",mEmail);
|
||||
|
||||
Log.e("Login", "jwt token: " + user);
|
||||
|
||||
try {
|
||||
Response<JwtToken> loginResponse = service.fakeValidate(user).execute();
|
||||
Log.e("Login", "jwt token: " + loginResponse.body());
|
||||
if (loginResponse.isSuccessful()) {
|
||||
String authToken = loginResponse.body().getToken();
|
||||
Log.e("Login", "jwt token: " + authToken);
|
||||
@ -335,12 +337,14 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.d("login failure",e.toString());
|
||||
Log.e("Login error", e.toString());
|
||||
} catch (Exception e) {
|
||||
Log.e("Login error", "nie udalo sie kurde...");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//To jest async i nie da sie zwrocic :(
|
||||
// Call<JwtToken> call = service.fakeValidate(user);
|
||||
//
|
||||
|
@ -7,6 +7,8 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
|
||||
@ -20,33 +22,120 @@ import retrofit2.Response;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private MapView mapView;
|
||||
|
||||
public List<Coordinate> getCoordinates() {
|
||||
return this.coordinates;
|
||||
}
|
||||
|
||||
public void setCoordinates(List<Coordinate> coordinates) {
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
public List<Coordinate> coordinates;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
setContentView(R.layout.activity_main);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
final String authToken = sharedPref.getString("authToken",null);
|
||||
|
||||
Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken);
|
||||
|
||||
Call<List<Coordinate>> call = service.getTopCoordinates();
|
||||
Call<List<Coordinate>> call = service.getOnlineCoordinates();
|
||||
|
||||
|
||||
call.enqueue(new Callback<List<Coordinate>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Coordinate>> call, Response<List<Coordinate>> response) {
|
||||
Log.e("MainActivity", "rsp: " + response.body());
|
||||
|
||||
setCoordinates(response.body());
|
||||
|
||||
|
||||
/* mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap,List<Coordinate> response) {
|
||||
|
||||
// Add the custom icon marker to the map
|
||||
for(Coordinate coord: response.body()){
|
||||
mapboxMap.addMarker(new MarkerOptions()
|
||||
.position(new LatLng(coord.getLatitude(), coord.getLongitude()))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<Coordinate>> call, Throwable t) {
|
||||
Toast.makeText(MainActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,14 @@ public class LdapUser {
|
||||
@SerializedName("email")
|
||||
private String email = null;
|
||||
|
||||
public LdapUser(String string, String mPassword, String string1, String pracownik, String string2, String string3, String mEmail) {
|
||||
public LdapUser(String login, String password, String department, String title, String firstName, String lastName, String email) {
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.department = department;
|
||||
this.title = title;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public LdapUser login(String login) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.MainActivity">
|
||||
@ -23,10 +24,13 @@
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView" />
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
mapbox:mapbox_cameraTargetLng="16.927002"
|
||||
mapbox:mapbox_cameraTargetLat="52.466799"
|
||||
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8"
|
||||
mapbox:mapbox_cameraZoom="17" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -17,4 +17,5 @@
|
||||
completions."
|
||||
</string>
|
||||
<string name="title_activity_main">MainActivity</string>
|
||||
<string name="access_token">pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user