.
This commit is contained in:
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-04-28T15:00:16.300542Z">
|
<DropdownSelection timestamp="2026-04-30T09:29:05.514328Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=b93659d0e5dd" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/Users/230405/.android/avd/Medium_Phone.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -84,54 +84,12 @@ public class HomeFragment extends Fragment {
|
|||||||
.navigate(com.example.cuida.R.id.action_home_to_schedule_appointment);
|
.navigate(com.example.cuida.R.id.action_home_to_schedule_appointment);
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- Feed Listener ---
|
|
||||||
loadFeed();
|
|
||||||
|
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFeed() {
|
|
||||||
com.google.firebase.auth.FirebaseAuth auth = com.google.firebase.auth.FirebaseAuth.getInstance();
|
|
||||||
if (auth.getCurrentUser() == null) return;
|
|
||||||
String userId = auth.getCurrentUser().getUid();
|
|
||||||
|
|
||||||
com.google.firebase.firestore.FirebaseFirestore.getInstance().collection("feed")
|
|
||||||
.whereEqualTo("userId", userId)
|
|
||||||
.orderBy("data", com.google.firebase.firestore.Query.Direction.DESCENDING)
|
|
||||||
.addSnapshotListener((value, error) -> {
|
|
||||||
if (error != null) return;
|
|
||||||
if (value != null && isAdded()) {
|
|
||||||
binding.layoutFeedContainer.removeAllViews();
|
|
||||||
if (value.isEmpty()) {
|
|
||||||
binding.layoutFeedContainer.addView(binding.textNoFeed);
|
|
||||||
} else {
|
|
||||||
for (com.google.firebase.firestore.DocumentSnapshot doc : value.getDocuments()) {
|
|
||||||
addFeedItem(doc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFeedItem(com.google.firebase.firestore.DocumentSnapshot doc) {
|
|
||||||
if (!isAdded()) return;
|
|
||||||
View itemView = getLayoutInflater().inflate(com.example.cuida.R.layout.item_feed, binding.layoutFeedContainer, false);
|
|
||||||
|
|
||||||
android.widget.TextView title = itemView.findViewById(com.example.cuida.R.id.feed_item_title);
|
|
||||||
android.widget.TextView content = itemView.findViewById(com.example.cuida.R.id.feed_item_content);
|
|
||||||
android.widget.TextView date = itemView.findViewById(com.example.cuida.R.id.feed_item_date);
|
|
||||||
|
|
||||||
title.setText(doc.getString("titulo"));
|
|
||||||
content.setText(doc.getString("conteudo"));
|
|
||||||
|
|
||||||
com.google.firebase.Timestamp ts = doc.getTimestamp("data");
|
|
||||||
if (ts != null) {
|
|
||||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd MMM, HH:mm", java.util.Locale.getDefault());
|
|
||||||
date.setText(sdf.format(ts.toDate()));
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.layoutFeedContainer.addView(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
|
|||||||
@@ -84,41 +84,6 @@
|
|||||||
app:iconGravity="textStart"
|
app:iconGravity="textStart"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_next_medication"/>
|
app:layout_constraintTop_toBottomOf="@id/card_next_medication"/>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text_feed_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Feed Clínico"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/primary_color"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/button_book_appointment"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"/>
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/text_feed_title"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/layout_feed_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text_no_feed"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Sem novos relatórios ou atualizações."
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:padding="24dp"
|
|
||||||
android:textColor="@android:color/darker_gray"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user