0% au considerat acest document util (0 voturi)
56 vizualizări31 pagini

PAM Lab6

Documentul prezintă implementarea unei aplicații mobile pentru telemedicină folosind Retrofit pentru consumul de servicii REST. Sunt descrise metodele API și implementarea în Android pentru înregistrare, autentificare, afișarea listei de medici și a detaliilor unui medic.

Încărcat de

Ion Cornea
Drepturi de autor
© All Rights Reserved
Respectăm cu strictețe drepturile privind conținutul. Dacă suspectați că acesta este conținutul dumneavoastră, reclamați-l aici.
Formate disponibile
Descărcați ca PDF, TXT sau citiți online pe Scribd
0% au considerat acest document util (0 voturi)
56 vizualizări31 pagini

PAM Lab6

Documentul prezintă implementarea unei aplicații mobile pentru telemedicină folosind Retrofit pentru consumul de servicii REST. Sunt descrise metodele API și implementarea în Android pentru înregistrare, autentificare, afișarea listei de medici și a detaliilor unui medic.

Încărcat de

Ion Cornea
Drepturi de autor
© All Rights Reserved
Respectăm cu strictețe drepturile privind conținutul. Dacă suspectați că acesta este conținutul dumneavoastră, reclamați-l aici.
Formate disponibile
Descărcați ca PDF, TXT sau citiți online pe Scribd

Ministerul Educaţiei al Republicii Moldova

Universitatea Tehnică a Moldovei


Facultatea Calculatoare Informatica si Microelectronica
Departamentul Ingineria Software si Automatica

RAPORT
Lucrarea de laborator nr. 6
Programarea aplicatiilor mobile
Tema: Telemedicine - SPRINT2

A efectuat: Cebotari Maxim


st. gr. TI-182

A verificat:
asist. univ. C. Rusu
Chisinau 2020

Scopul lucrarii

Scopul lucrării de laborator

Pentru designul ofert in laboratorul nr. 5 să se implementeze partea funcțională a proiectului conform
serviciului API descris mai jos.
Metodele oferite de Servicu:
• Auth (autentificare)
• Reg (inregistrare)
• UserProfie (extragerea avansată despre utilizatorul curent autentificat)
• UpdateUserProfile (NotImplemented) - nu cred că o voi implementa
• GetDocList (vizualizarea listei de medici activi in sistem)
• GetDoc (vizualizarea unui anumit medici activ in sistem)
• UserRequestConsultation (Adaugarea unei programari la medic)

Desfasurarea lucrarii de laborator


Retrofit Android
Retrofit este un client REST sigur pentru tip pentru Android și Java, care are ca scop facilitarea
consumului de servicii web RESTful. Retrofit 2 are multe funcții noi și un API intern modificat în comparație
cu versiunile anterioare. Retrofit serializează automat răspunsul JSON folosind un POJO (Plain Old Java
Object) care trebuie definit în avansat pentru structura JSON. Pentru a serializa JSON avem nevoie de un
convertor pentru al converti mai întâi în Gson. Trebuie să adăugăm următoarele dependențe în fișierul nostru
[Link].
compile '[Link].retrofit2:retrofit:2.1.0'
compile '[Link]:gson:2.6.2'
compile '[Link].retrofit2:converter-gson:2.1.0'

1. Register

Server:
[API REG] POST
~/api/Register/UserReg
Header - Content-Type:application/x-www-form-urlencoded

Body
Content-Type:application/x-www-form-urlencoded
FullName=
Birthday= {FORMAT yyyy/MM/dd}
Email=
Phone=
Address=
Username=
Password=
Base64Photo {string:base64}=

SUCCESS {STATUS CODE 201}


Android:
([Link])
@FormUrlEncoded
@POST("api/Register/UserReg/")
Call<UserReg> register(
@Field("FullName") String fullname,
@Field("Birthday") String birthday,
@Field("Email") String email,
@Field("Phone") String phone,
@Field("Address") String address,
@Field("Username") String username,
@Field("Password") String password,
@Field("Base64Photo") String photo
);
(Sign_up.java)
Retrofit retrofit = new [Link]()
.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<UserReg> call = [Link](


[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
photo); //Static Var → in anexa este codfificarea foto

[Link](new Callback<UserReg>() {
@Override
public void onResponse(Call<UserReg> call, Response<UserReg> response) {
[Link](getApplicationContext(), "Este necesara logarea.",
Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), [Link]));
}

@Override
public void onFailure(Call<UserReg> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});
Design:

La inregistrarea cu success, utilizatorul va fi rederictionat catre pagina de logare (este posibil de


apelat functia cu auto logare). Mesajul de eroare va fi afisat in cazul procesului esuat.
2. Logare
Server:
[API AUTH] POST
~/api/Login/UserAuth
Header - Content-Type:application/x-www-form-urlencoded
Body
Content-Type:application/x-www-form-urlencoded
Email=
Password=

RESULT

"Status": "SUCCESS",
"Message": "TOKEN" < - need to be saved for future usage.
}

Android:
([Link])
@FormUrlEncoded
@POST("api/Login/UserAuth/")
Call<UserAuth> auth(
@Field("Email") String email,
@Field("Password") String password
);

([Link])
Retrofit retrofit = new [Link]()
.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<UserAuth> call = [Link](email,password);


//Call<UserAuth> call = [Link]("[Link]@[Link]","maxim1908");

[Link](new Callback<UserAuth>() {
@Override
public void onResponse(Call<UserAuth> call, Response<UserAuth> response) {

if ([Link]() != null) {
Log.e("TOKEN: ", [Link]().getMessage());
[Link] editor = getSharedPreferences("TOKEN",
MODE_PRIVATE).edit();
[Link]("TOKEN", [Link]().getMessage());
[Link]();
startActivity(new Intent(getApplicationContext(), Home_screen.class));
} else {
[Link](getApplicationContext(), "Login sau Parola incorecta.",
Toast.LENGTH_SHORT).show();
}

@Override
public void onFailure(Call<UserAuth> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

Design:

In cazul in care Login/Parola este gresita utilizatorul este informat. In caz contrar, de la server se va
primi token-ul, iar utilizatorul este redirictionat catre urmatoarea pagina.
3. Doctor List
Server:
[API DOC LIST] GET
~/api/Doctor/GetDoctorList
Header - Content-Type:application/x-www-form-urlencoded
token=TOKEN

RESULT

{
"DocId": 1,
"FullName": "Arseni Andrei",
"Specs": "Oculist",
"Address": "str. Vasile Alecsandri 45A",
"About": "Medic Oculist cu experienta de 12 ani in domeniu.",
"Stars": 4.2,
"Photo": "base64:string"
},
{
"DocId": 2,
"FullName": "Stratila Alina",
"Specs": "Pediatru",
"Address": "str. Mihai Eminescu 12/3",
"About": "Medic Pediatru cu experienta de 7 ani in domeniu.",
"Stars": 4.8,
"Photo": "base64:string"
},

Android:
([Link])
@GET("api/Doctor/GetDoctorList/")
Call<List<API_Doctor_list>> docList(
@Header("token") String token,
@Header("Content-Type") String content_type
);
(Doctor_list.java)
Retrofit retrofit = new [Link]()
.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);


Call<List<API_Doctor_list>> call = [Link](token, "application/x-www-form-urlencoded");
[Link](new Callback<List<API_Doctor_list>>() {
@Override
public void onResponse(Call<List<API_Doctor_list>> call, Response<List<API_Doctor_list>>
response) {
List<API_Doctor_list> api_doctor_lists = [Link]();
for (API_Doctor_list apiDoctorList : api_doctor_lists){
Log.e("Name: ", [Link]());
structure(
[Link](),
[Link](),
[Link](),
[Link]([Link]()),
[Link](),
[Link]());

}
}

@Override
public void onFailure(Call<List<API_Doctor_list>> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

Design:
Fiecare field se genereaza apare pentru fiecare doctor in mod automat (cu ajutorul functie
structure()) vezi anexa.

4. Doc Info
Server:
[API DOC {id}] GET
~/api/Doctor/GetDoctor/1
Header - Content-Type:application/x-www-form-urlencoded
token=TOKEN

RESULT

{
"DocId": 1,
"FullName": "Arseni Andrei",
"Specs": "Oculist",
"Address": "str. Vasile Alecsandri 45A",
"About": "Medic Oculist cu experienta de 12 ani in domeniu.",
"Stars": 4.2,
"Photo": "base64:string"
},

Android:
([Link])
@GET("api/Doctor/GetDoctor/{id}")
Call<API_DocInfo> docInfo(
@Path("id") Integer id,
@Header("token") String token,
@Header("Content-Type") String content_type
);

(Doctor_details.java)
Retrofit retrofit = new [Link]()
.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);


Call<API_DocInfo> call = [Link]([Link](docID), token, "application/x-www-form-
urlencoded");
[Link](new Callback<API_DocInfo>() {
@Override
public void onResponse(Call<API_DocInfo> call, Response<API_DocInfo> response) {
Log.e("ID: ", [Link]([Link]().getDocId()));
Log.e("Name: ", [Link]().getFullName());
Log.e("Spesc: ", [Link]().getSpecs());
Log.e("Address: ", [Link]().getAddress());
Log.e("About: ", [Link]().getAbout());
Log.e("Stars: ", [Link]([Link]().getStars()));
Log.e("Photo: ", "Alta data");

byte[] decodedString = [Link]([Link]().getPhoto(), [Link]);


Bitmap decodedByte = [Link](decodedString, 0,
[Link]);

profile_image.setImageBitmap(decodedByte);
[Link]([Link]().getFullName());
[Link]([Link]().getSpecs());
[Link]([Link]([Link]().getStars()));
[Link]([Link]().getAbout());
[Link]([Link]().getAddress());

address = [Link]().getAddress();
name = [Link]().getFullName();
}

@Override
public void onFailure(Call<API_DocInfo> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

Design:
Am implement si GMap care afiseaza pe harta locatia. De aceasta determinarea Lat Long se ocupa
Geocoder (vezi anexa).

5. Consulatie Request
Server:
[API CONSULTATION REQUEST] POST
~/api/Doctor/AddConsultation
Header - Content-Type:application/x-www-form-urlencoded
token=TOKEN

RESULT

"ConsId": 1,
"Name": "",
"Disease": "",
"Address": "",
"Description": "",
"DocId": 5,
"IsConfirmed": false
}

Android:
([Link])
@FormUrlEncoded
@POST("api/Doctor/AddConsultation/")
Call<ConsDet> approve(
@Field("ConsId") int consid,
@Field("Name") String name,
@Field("Disease") String disease,
@Field("Address") String address,
@Field("Description") String desc,
@Field("DocId") int docid,
@Field("IsConfirmed") Boolean bool
);

(Approve_notification.java)
Retrofit retrofit = new [Link]()
.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<ConsDet> call = [Link](1,


[Link]("name", "No Name"),
[Link]("desease", "No desease"),
[Link]("location", "No location"),
[Link]("description", "No description"),
docid,
false);

[Link](new Callback<ConsDet>() {
@Override
public void onResponse(Call<ConsDet> call, Response<ConsDet> response) {
[Link](getApplicationContext(), "Cerere plasata",
Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), Home_screen.class));
}

@Override
public void onFailure(Call<ConsDet> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

Design:
Anexe:

[Link]
package [Link];

import [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import static [Link].MODE_PRIVATE;

public interface API {

@FormUrlEncoded
@POST("api/Register/UserReg/")
Call<UserReg> register(
@Field("FullName") String fullname,
@Field("Birthday") String birthday,
@Field("Email") String email,
@Field("Phone") String phone,
@Field("Address") String address,
@Field("Username") String username,
@Field("Password") String password,
@Field("Base64Photo") String photo
);

@FormUrlEncoded
@POST("api/Login/UserAuth/")
Call<UserAuth> auth(
@Field("Email") String email,
@Field("Password") String password
);

@GET("api/Doctor/GetDoctorList/")
Call<List<API_Doctor_list>> docList(
@Header("token") String token,
@Header("Content-Type") String content_type
);

@GET("api/Doctor/GetDoctor/{id}")
Call<API_DocInfo> docInfo(
@Path("id") Integer id,
@Header("token") String token,
@Header("Content-Type") String content_type
);

@FormUrlEncoded
@POST("api/Doctor/AddConsultation/")
Call<ConsDet> approve(
@Field("ConsId") int consid,
@Field("Name") String name,
@Field("Disease") String disease,
@Field("Address") String address,
@Field("Description") String desc,
@Field("DocId") int docid,
@Field("IsConfirmed") Boolean bool
);
}
[Link]
package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link].Base64;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Sign_up extends AppCompatActivity {

Button btnNext;
ImageButton btnBack;
String photo =
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNMT0zfBA
AESQHjMAmi3AAAAABJRU5ErkJggg==";
EditText name, birthday, email, phone, address, username, password;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);

setContentView([Link].activity_sign_up);

btnBack = findViewById([Link]);
btnNext = findViewById([Link]);
name = findViewById([Link]);
birthday = findViewById([Link]);
email = findViewById([Link]);
phone = findViewById([Link]);
address = findViewById([Link]);
username = findViewById([Link]);
password = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {

/* *** Script for encoding photo to Base64


InputStream inputStream = new FileInputStream(uploadedPhoto);
byte[] bytes;
byte[] buffer = new byte[8192];
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();

try {
while ((bytesRead = [Link](buffer)) != -1) {
[Link](buffer, 0, bytesRead);
}
}
catch (IOException e) {
[Link]();
}

bytes = [Link]();
String encodedString = [Link](bytes, [Link]);
*/

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<UserReg> call = [Link](


[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
[Link]().toString(),
photo);

[Link](new Callback<UserReg>() {
@Override
public void onResponse(Call<UserReg> call, Response<UserReg> response) {
[Link](getApplicationContext(), "Este necesara logarea.",
Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), [Link]));
}

@Override
public void onFailure(Call<UserReg> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

}
});

[Link](new [Link]() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), [Link]));
}
});
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Login extends AppCompatActivity {

Button login;
TextView signUp;
EditText editEmail, editPass;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);

setContentView([Link].activity_login);

login = findViewById([Link]);
signUp = findViewById([Link]);
editEmail = findViewById([Link]);
editPass = findViewById([Link]);

[Link](v -> startActivity(new Intent(getApplicationContext(), Sign_up.class)));

[Link](v -> {

String email = [Link]().toString();


String password = [Link]().toString();

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<UserAuth> call = [Link](email,password);


//Call<UserAuth> call = [Link]("[Link]@[Link]","maxim1908");
[Link](new Callback<UserAuth>() {
@Override
public void onResponse(Call<UserAuth> call, Response<UserAuth> response) {

if ([Link]() != null) {
Log.e("TOKEN: ", [Link]().getMessage());
[Link] editor = getSharedPreferences("TOKEN",
MODE_PRIVATE).edit();
[Link]("TOKEN", [Link]().getMessage());
[Link]();
startActivity(new Intent(getApplicationContext(), Home_screen.class));
} else {
[Link](getApplicationContext(), "Login sau Parola incorecta.",
Toast.LENGTH_SHORT).show();
}

@Override
public void onFailure(Call<UserAuth> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});
});

}
}
Home_Screen.java
package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Home_screen extends AppCompatActivity {

Button btnRequest;
EditText name, desease, location, description;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_home_screen);
btnRequest = findViewById([Link]);
name = findViewById([Link]);
desease = findViewById([Link]);
location = findViewById([Link]);
description = findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link] editor = getSharedPreferences("Request", MODE_PRIVATE).edit();
[Link]("name", [Link]().toString());
[Link]("desease", [Link]().toString());
[Link]("location", [Link]().toString());
[Link]("description", [Link]().toString());
[Link]();
startActivity(new Intent(getApplicationContext(), Doctor_list.class));
}
});
}
}
Doctor_List.java
package [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Base64;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Doctor_list extends AppCompatActivity {

ConstraintLayout docSelect;
LinearLayout parentLayout;
CircleImageView profile_image;
TextView textView9, nota, textView10, address;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_doctor_list);

docSelect = findViewById([Link]);
parentLayout = findViewById([Link]);
profile_image = findViewById([Link].profile_image);
textView9 = findViewById([Link].textView9);
nota = findViewById([Link]);
textView10 = findViewById([Link].textView10);
address = findViewById([Link]);

[Link]([Link]);

SharedPreferences prefs = getSharedPreferences("TOKEN", MODE_PRIVATE);


String token = [Link]("TOKEN", "No TOKEN defined");

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);


Call<List<API_Doctor_list>> call = [Link](token, "application/x-www-form-urlencoded");
[Link](new Callback<List<API_Doctor_list>>() {
@Override
public void onResponse(Call<List<API_Doctor_list>> call, Response<List<API_Doctor_list>>
response) {
List<API_Doctor_list> api_doctor_lists = [Link]();
for (API_Doctor_list apiDoctorList : api_doctor_lists){
Log.e("Name: ", [Link]());

structure(
[Link](),
[Link](),
[Link](),
[Link]([Link]()),
[Link](),
[Link]());

}
}

@Override
public void onFailure(Call<List<API_Doctor_list>> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

void structure(int docID, String ph, String nam, String st, String spe, String loc){
ConstraintLayout doc = new ConstraintLayout(getApplicationContext());

[Link]([Link]());
[Link]([Link]);

CircleImageView photo = (CircleImageView) getLayoutInflater().inflate([Link], null);


[Link](profile_image.getLayoutParams());

byte[] decodedString = [Link](ph, [Link]);


Bitmap decodedByte = [Link](decodedString, 0, [Link]);

[Link](decodedByte);
[Link](photo);
TextView name = (TextView)getLayoutInflater().inflate([Link], null);
[Link]([Link]());
[Link](nam);
[Link](name);

TextView stars = (TextView)getLayoutInflater().inflate([Link], null);


[Link]([Link]());
[Link](st);
[Link](stars);

TextView specs = (TextView)getLayoutInflater().inflate([Link], null);


[Link]([Link]());
[Link](spe);
[Link](specs);

TextView location = (TextView)getLayoutInflater().inflate([Link], null);


[Link](loc);
[Link]([Link]());
[Link](location);

[Link](new [Link]() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getBaseContext(), Doctor_details.class);
[Link]("docID", [Link](docID));
startActivity(intent);
}
});

[Link](doc);
}
}
Doctor_details.java
package [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Base64;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Doctor_details extends AppCompatActivity implements OnMapReadyCallback {

Button btnRequest1;
TextView textView9, textView10, textView7, descr, textView8;
MapView gmap;

CircleImageView profile_image;
GoogleMap map;
String name, address;
Address locatie;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);

setContentView([Link].activity_doctor_details);

btnRequest1 = findViewById([Link].btnRequest1);
textView9 = findViewById([Link].textView9);
textView10 = findViewById([Link].textView10);
textView7 = findViewById([Link].textView7);
descr = findViewById([Link]);
textView8 = findViewById([Link].textView8);
gmap = findViewById([Link]);
profile_image = findViewById([Link].profile_image);

[Link](savedInstanceState);
[Link](this);

String docID = getIntent().getStringExtra("docID");

[Link](new [Link]() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getBaseContext(), Approve_notification.class);
[Link]("docID", [Link](docID));
startActivity(intent);
}
});

SharedPreferences prefs = getSharedPreferences("TOKEN", MODE_PRIVATE);


String token = [Link]("TOKEN", "No TOKEN defined");

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);


Call<API_DocInfo> call = [Link]([Link](docID), token, "application/x-www-form-
urlencoded");
[Link](new Callback<API_DocInfo>() {
@Override
public void onResponse(Call<API_DocInfo> call, Response<API_DocInfo> response) {
Log.e("ID: ", [Link]([Link]().getDocId()));
Log.e("Name: ", [Link]().getFullName());
Log.e("Spesc: ", [Link]().getSpecs());
Log.e("Address: ", [Link]().getAddress());
Log.e("About: ", [Link]().getAbout());
Log.e("Stars: ", [Link]([Link]().getStars()));
Log.e("Photo: ", "Alta data");

byte[] decodedString = [Link]([Link]().getPhoto(), [Link]);


Bitmap decodedByte = [Link](decodedString, 0,
[Link]);

profile_image.setImageBitmap(decodedByte);
[Link]([Link]().getFullName());
[Link]([Link]().getSpecs());
[Link]([Link]([Link]().getStars()));
[Link]([Link]().getAbout());
[Link]([Link]().getAddress());

address = [Link]().getAddress();
name = [Link]().getFullName();
}

@Override
public void onFailure(Call<API_DocInfo> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
[Link]().setMyLocationButtonEnabled(false);
if ([Link](this, [Link].ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && [Link](this,
[Link].ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
{
[Link](getApplicationContext(), "Reject Permissions", Toast.LENGTH_SHORT).show();
return;
}
[Link](true);
try {
[Link](getApplicationContext());
} catch (Exception e) {
[Link]();
}

final Handler handler = new Handler();


[Link](new Runnable() {
@Override
public void run() {
Log.e("Geocoder: ", address);

Geocoder gc = new Geocoder(getApplicationContext());


try {
List<Address> list = [Link](address, 1);
locatie = [Link](0);
} catch (IOException e) {
[Link]();
}

LatLng docloc = new LatLng([Link](), [Link]());


[Link](new MarkerOptions()
.position(docloc)
.title(name));
[Link]([Link](docloc));

CameraUpdate cameraUpdate = [Link](docloc, 18);


[Link](cameraUpdate);
}
}, 2000);

@Override
public void onResume() {
[Link]();
[Link]();
}
}
Approve_notification.java
package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Base64;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Approve_notification extends AppCompatActivity {

TextView name, desease, location, description;


CircleImageView profile_image;
TextView docname, docspec, star;
Button btnRequest2, cancelRequest;
int docid;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_approve_notification);

name = findViewById([Link]);
desease = findViewById([Link]);
location = findViewById([Link]);
description = findViewById([Link]);
docname = findViewById([Link].textView9);
profile_image = findViewById([Link].profile_image);
docspec = findViewById([Link].textView10);
star = findViewById([Link].textView7);
btnRequest2 = findViewById([Link].btnRequest2);
cancelRequest = findViewById([Link]);

SharedPreferences prefs = getSharedPreferences("Request", MODE_PRIVATE);


[Link]([Link]("name", "No Name"));
[Link]([Link]("desease", "No desease"));
[Link]([Link]("location", "No location"));
[Link]([Link]("description", "No description"));

String docID = getIntent().getStringExtra("docID");

SharedPreferences tok = getSharedPreferences("TOKEN", MODE_PRIVATE);

String token = [Link]("TOKEN", "No TOKEN defined");

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);


Call<API_DocInfo> call = [Link]([Link](docID), token, "application/x-www-form-
urlencoded");
[Link](new Callback<API_DocInfo>() {
@Override
public void onResponse(Call<API_DocInfo> call, Response<API_DocInfo> response) {
Log.e("ID: ", [Link]([Link]().getDocId()));
Log.e("Name: ", [Link]().getFullName());
Log.e("Spesc: ", [Link]().getSpecs());
Log.e("Address: ", [Link]().getAddress());
Log.e("About: ", [Link]().getAbout());
Log.e("Stars: ", [Link]([Link]().getStars()));
Log.e("Photo: ", "IMG");

byte[] decodedString = [Link]([Link]().getPhoto(), [Link]);


Bitmap decodedByte = [Link](decodedString, 0,
[Link]);

profile_image.setImageBitmap(decodedByte);

[Link]([Link]().getFullName());
[Link]([Link]().getSpecs());
[Link]([Link]([Link]().getStars()));
docid = [Link]().getDocId();
}

@Override
public void onFailure(Call<API_DocInfo> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});

[Link](new [Link]() {
@Override
public void onClick(View v) {

Retrofit retrofit = new [Link]()


.baseUrl("[Link]
.addConverterFactory([Link]())
.build();

API api = [Link]([Link]);

Call<ConsDet> call = [Link](1,


[Link]("name", "No Name"),
[Link]("desease", "No desease"),
[Link]("location", "No location"),
[Link]("description", "No description"),
docid,
false);

[Link](new Callback<ConsDet>() {
@Override
public void onResponse(Call<ConsDet> call, Response<ConsDet> response) {
[Link](getApplicationContext(), "Cerere plasata",
Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), Home_screen.class));
}

@Override
public void onFailure(Call<ConsDet> call, Throwable t) {
[Link](getApplicationContext(), [Link](), Toast.LENGTH_LONG).show();
}
});
}
});

[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link](getApplicationContext(), "Canceled", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), Home_screen.class));
}
});
}
}

S-ar putea să vă placă și