Commit ceae49b9 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

AGILE#307: Adjusted recurring time of background service.

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 2632dbdf
......@@ -27,7 +27,7 @@ public class NotificationReturn implements Parcelable{
public String reminderTime;
@SerializedName("read")
public int hasRead;
public boolean hasRead;
@SerializedName("content")
public String description;
......@@ -35,6 +35,8 @@ public class NotificationReturn implements Parcelable{
@SerializedName("reminder_email")
public String emailAddress;
//todo: Mudar para boolean quando o back-end atualizar
@SerializedName("reminder_email_sent")
public int emailSent;
......@@ -53,7 +55,7 @@ public class NotificationReturn implements Parcelable{
scheduleId = pc.readLong();
resourceScheduleId = pc.readLong();
reminderTime = pc.readString();
hasRead = pc.readInt();
hasRead = pc.readByte() != 0;
description = pc.readString();
emailAddress = pc.readString();
emailSent = pc.readInt();
......@@ -84,7 +86,7 @@ public class NotificationReturn implements Parcelable{
dest.writeLong(scheduleId == null ? 0 : scheduleId);
dest.writeLong(resourceScheduleId == null ? 0 : resourceScheduleId);
dest.writeString(reminderTime == null ? "" : reminderTime);
dest.writeInt(hasRead);
dest.writeByte((byte) (hasRead ? 1 : 0));
dest.writeString(description == null ? "" : description);
dest.writeString(emailAddress == null ? "" : emailAddress);
dest.writeInt(emailSent);
......
......@@ -95,7 +95,7 @@ public interface ApiEndpoints {
@GET("forms/schedule_history?permission=citizen")
Call<FormFilters> requestCitizenSectors();
@POST("notifications?permission=2")
@POST("notifications?permission=citizen")
Call<NotificationReturn> requestCreateNotification(@Body Notification notification);
@GET("schedules/{id_schedule}?permission=citizen")
......
......@@ -172,7 +172,7 @@ public class LoginPresenter extends BasePresenter<LoginView> {
.setService(ImageUpdateService.class)
.setTag(Utils.SERVICE_UPDATE_IMAGE)
//time the function gets is in seconds, 60s = 1 minutes, 1 hour = 3600
.setTrigger(Trigger.executionWindow(60, 3600))
.setTrigger(Trigger.executionWindow(580, 610))
//will be retried if it fails.
.setRecurring(true)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
......
......@@ -93,6 +93,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
header.put(Utils.CLIENT, osb.getString(Utils.CLIENT, null));
header.put(Utils.UID, osb.getString(Utils.UID, null));
final ApiEndpoints service = ApiUtils.request(header);
Call<ScheduleConfirmation> listCall = service.requestConfirmSchedule(schedule.getmId(), citizen.getId());
......
......@@ -83,12 +83,15 @@ public class NotificationsListService extends JobService {
Gson gson = new Gson();
LongSparseArray<NotificationReturn> newLocalNotifications = new LongSparseArray<>();
List<NotificationReturn> list = LocalNotificationManager.getList(osb, gson);
Log.d("Notificacao", "NOTIFICACOES LOCAIS!!!!!!!!!");
for(NotificationReturn n : list){
newLocalNotifications.append(n.notificationId, n);
Log.d("Notificacao", gson.toJson(n));
}
Log.d("Notificacao", "NOTIFICACOES NO SERVIDOR");
for(NotificationReturn nr : responseList){
if(newLocalNotifications.get(nr.notificationId) == null && nr.hasRead == 0){
Log.d("Notificacao", gson.toJson(nr));
if(newLocalNotifications.get(nr.notificationId) == null && nr.hasRead){
LocalNotificationManager.createLocalNotification(getApplicationContext(),
nr, osb, gson);
}
......@@ -100,6 +103,7 @@ public class NotificationsListService extends JobService {
break;
default:
Log.e("Server response", getClass().getName() + ": ERRO:" + status);
jobFinished(job, false);
break;
}
......
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