Skip to content

Commit

Permalink
#5633 Implemented sheit
Browse files Browse the repository at this point in the history
  • Loading branch information
onero authored May 1, 2018
2 parents 0dff656 + 6f34cbc commit 59da824
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/dk/adamino/rehabilitation/BE/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
public class Client extends User {
public String address;
public String phone;
public RehabilitationPlan rehabilitationPlan;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dk.adamino.rehabilitation.BE;

/**
* Created by Adamino.
*/
public class RehabilitationPlan {
public String uid;
public String diagnosis;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,15 @@ public class FirestoreDAO implements IFirestore {
private FirebaseFirestore mFirestore = FirebaseFirestore.getInstance();

@Override
public void getClientById(String clientUID, final IFirestoreCallback firestoreCallback) {
public void getClientByIdAsync(String clientUID, final IFirestoreCallback firestoreCallback) {
DocumentReference docRef = mFirestore.collection(USERS_COLLECTION).document(clientUID);
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Client client = new Client();
client.uid = document.getId();
client.fullName = document.getString("fullName");
client.email = document.getString("email");
client.phone = document.getString("phone");
client.address = document.getString("address");
Client client = task.getResult().toObject(Client.class);
firestoreCallback.onClientResponse(client);
Log.d(TAG, "DocumentSnapshot data: " + document.getData());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface IFirestore {
* @param uid
* @return Client
*/
void getClientById(String uid, IFirestoreCallback firestoreCallback);
void getClientByIdAsync(String uid, IFirestoreCallback firestoreCallback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public static FirebaseClientModel getInstance() {
* Get currently logged in client
* @param response
*/
public void getLoggedInClient(IFirestoreCallback response) {
public void loadLoggedInClientAsync(IFirestoreCallback response) {
// TODO ALH: Replace!
String adamUID = "7fdjYuWZC1ZQD4npgb1YG3kfNK02";
mFirestoreDAO.getClientById(adamUID, response);
mFirestoreDAO.getClientByIdAsync(adamUID, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ProfileActivity extends AppCompatActivity implements IFirestoreCallback {
public static final String TAG = "GUI";

private TextView mName, mPhone, mEmail;
private TextView mName, mPhone, mEmail, mDiagnosis;

private FirebaseClientModel mClientModel;

Expand All @@ -28,17 +28,23 @@ protected void onCreate(Bundle savedInstanceState) {
mName = findViewById(R.id.txtName);
mPhone = findViewById(R.id.txtPhone);
mEmail = findViewById(R.id.txtEmail);
mDiagnosis = findViewById(R.id.txtDiagnosis);

mClientModel.getLoggedInClient(this);
// Load logged in client async
mClientModel.loadLoggedInClientAsync(this);
}

/**
* When data is loaded, set client information
*/
private void setClientInformation(Client loggedInClient) {
// Client info
mName.setText(loggedInClient.fullName);
mPhone.setText(loggedInClient.phone);
mEmail.setText(loggedInClient.email);

// Rehabilitation Plan
mDiagnosis.setText(loggedInClient.rehabilitationPlan.diagnosis);
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
android:layout_height="match_parent"
tools:context=".GUI.ProfileActivity">

<!--USER INFORMATION-->

<ImageView
android:id="@+id/imageView"
android:layout_width="107dp"
Expand All @@ -24,7 +26,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:layout_marginTop="8dp"
android:text="Loading data"
android:text="@string/loading_data"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView"/>

Expand All @@ -46,6 +48,8 @@
app:layout_constraintStart_toStartOf="@+id/txtPhone"
app:layout_constraintTop_toBottomOf="@+id/txtPhone"/>

<!--REHABILITATION PLAN-->

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
Expand All @@ -61,7 +65,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text=""
android:text="@string/loading_data"
app:layout_constraintEnd_toEndOf="@+id/txtEmail"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/textView6"/>
Expand All @@ -81,7 +85,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text=""
android:text="@string/loading_data"
app:layout_constraintStart_toStartOf="@+id/txtDiagnosis"
app:layout_constraintTop_toBottomOf="@+id/textView9"
/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<string name="profile_image">Profile Image</string>
<string name="diagnosis">Diagnosis</string>
<string name="goal">Goal</string>
<string name="loading_data">Loading data</string>
</resources>

0 comments on commit 59da824

Please sign in to comment.