Commit 3954a365 authored by Ishankha K.C's avatar Ishankha K.C

Notification Log connected

parent 94ec69b4
......@@ -17,6 +17,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.BabyCare"
tools:targetApi="31">
<activity
android:name=".activities.ActivityLogsActivity"
android:exported="false" />
<activity
android:name=".activities.LiveFeedActivity"
android:exported="false" />
......
......@@ -65,6 +65,7 @@ public class BabyDashboardActivity extends AppCompatActivity implements AddBabyD
private BabyApiService babyApiService;
private BabyDashboardAdapter adapter;
private List<BabyDto> babyDtoList = new ArrayList<>();
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
......
......@@ -47,7 +47,8 @@ public class DashboardActivity extends AppCompatActivity {
});
btn3.setOnClickListener(v -> {
Intent intent = new Intent(this, ActivityLogsActivity.class);
startActivity(intent);
});
btn4.setOnClickListener(v -> {
......
package com.kaluwa.enterprises.babycare.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.dto.ActivityLogDto;
import java.util.List;
public class ActivityLogsAdapter extends RecyclerView.Adapter<ActivityLogsAdapter.ActivityLogItemHolder> {
private final static String TAG = "ActivityLogAdapter";
private Context context;
private List<ActivityLogDto> activityLogList;
public ActivityLogsAdapter(Context context, List<ActivityLogDto> activityLogList) {
this.context = context;
this.activityLogList = activityLogList;
}
@NonNull
@Override
public ActivityLogsAdapter.ActivityLogItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item_activity_log, parent, false);
return new ActivityLogsAdapter.ActivityLogItemHolder(view);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull ActivityLogsAdapter.ActivityLogItemHolder holder, int position) {
ActivityLogDto activityLogDto = activityLogList.get(position);
holder.tvActivityLogId.setText(activityLogDto.getActivityLogId().toString());
holder.tvActivityType.setText(activityLogDto.getActivityLogType());
holder.tvDescription.setText(activityLogDto.getActivityLogDescription());
}
@Override
public int getItemCount() {
return activityLogList.size();
}
public static class ActivityLogItemHolder extends RecyclerView.ViewHolder {
public TextView tvActivityLogId, tvActivityType, tvDescription;
public ActivityLogItemHolder(@NonNull View view) {
super(view);
tvActivityLogId = view.findViewById(R.id.tvActivityLogId);
tvActivityType = view.findViewById(R.id.tvActivityType);
tvDescription = view.findViewById(R.id.tvDescription);
}
}
}
......@@ -59,7 +59,7 @@ public class BabyDashboardAdapter extends RecyclerView.Adapter<BabyDashboardAdap
String sex = babyDto.getSex();
String notes = babyDto.getNotes();
Boolean isActive = babyDto.getIsActive();
InputStream imageData = babyDto.getImageData();
byte[] imageData = babyDto.getImageData();
if (lastname != null) {
holder.tvBabyName.setText(firstname + " " + lastname);
......
......@@ -6,6 +6,7 @@ import static com.kaluwa.enterprises.babycare.constants.Configs.BASE_URL;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.kaluwa.enterprises.babycare.service.ActivityLogsApiService;
import com.kaluwa.enterprises.babycare.service.AuthApiService;
import com.kaluwa.enterprises.babycare.service.BabyApiService;
import com.kaluwa.enterprises.babycare.service.DocumentApiService;
......@@ -77,4 +78,9 @@ public class ApiConfig {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(DocumentApiService.class);
}
public ActivityLogsApiService getActivityLogsApi(String JWTToken) {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(ActivityLogsApiService.class);
}
}
package com.kaluwa.enterprises.babycare.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ActivityLogDto {
private Long activityLogId;
private String activityLogType;
private String activityLogDescription;
}
......@@ -49,9 +49,7 @@ public class BabyDto {
private UserDto user;
private Long userId;
private Long documentId;
@JsonIgnore
private InputStream imageData;
private byte[] imageData;
@JsonIgnore
private boolean sys_validated;
......
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.ActivityLogDto;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
public interface ActivityLogsApiService {
@GET("activity-logs")
Call<List<ActivityLogDto>> getAllActivityLogs();
}
......@@ -223,6 +223,16 @@ public class Utils {
}
}
public static Bitmap convertByteArrayToBitmap(byte[] byteArray) {
try {
return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
} catch (Exception e) {
Log.e(TAG, "Error decoding image byte array: " + e.getMessage());
throw new RuntimeException("Error decoding image byte array");
}
}
public static int dpToPx(Context context, int dp) {
float density = context.getResources().getDisplayMetrics().density;
return Math.round(dp * density);
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
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"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.ActivityLogsActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/appbar"/>
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/b_care_action_bar"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/background"
android:contentDescription="background-image"
android:scaleType="centerCrop"
android:alpha="0.4"/>
<RelativeLayout
android:id="@+id/rl_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rl_background"
android:backgroundTint="#62178F"
app:layout_constraintTop_toTopOf="@+id/background"
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
android:padding="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Activity Notifications"
android:textAlignment="center"
android:textColor="@color/white"
android:textAllCaps="true"
android:fontFamily="@font/inknut_antiqua_regular"
android:textSize="20sp"
android:gravity="center"/>
</RelativeLayout>
<!-- Header Row for the Table -->
<LinearLayout
android:id="@+id/headerRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/gray"
android:paddingTop="6dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingBottom="6dp"
app:layout_constraintTop_toBottomOf="@id/rl_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="Id"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Activity Type"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Description"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
</LinearLayout>
<!-- RecyclerView for the Table Content -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_activity_notifications"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/headerRow"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
app:layout_constraintStart_toStartOf="@id/background"
android:scrollbars="none"
android:paddingTop="6dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingBottom="6dp"/>
<TextView
android:id="@+id/no_content_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No content available"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textStyle="bold"
android:visibility="gone"/>
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99D5C5DF"
android:visibility="gone"
android:clickable="true"
android:focusable="true"/>
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/progress_bar"
style="@style/SpinKitView.Large.DoubleBounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:SpinKit_Color="@color/purple"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<TextView
android:id="@+id/tvActivityLogId"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="Id"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/tvActivityType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Activity Type"
android:textSize="16sp" />
<TextView
android:id="@+id/tvDescription"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Description"
android:textSize="16sp" />
</LinearLayout>
\ No newline at end of file
......@@ -9,4 +9,5 @@
<color name="cancel_dark_red">#CC0000</color>
<color name="success_green">#28A745</color>
<color name="success_dark_green">#218838</color>
<color name="gray">#D3D3D3</color> <!-- Light gray color -->
</resources>
\ No newline at end of file
......@@ -12,4 +12,5 @@
<color name="cancel_dark_red">#CC0000</color>
<color name="success_green">#28A745</color>
<color name="success_dark_green">#218838</color>
<color name="gray">#D3D3D3</color> <!-- Light gray color -->
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment