Commit 65b47b50 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

AGILE#307: Adjusted recurring time of background service (NotificationListService).

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent ceae49b9
......@@ -215,29 +215,8 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void afterSuccessfulLogin() {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(
new GooglePlayDriver(this)
);
Job job = dispatcher.newJobBuilder()
.setService(NotificationsListService.class)
.setTag(Utils.NOTIFICATION_UPDATE_LIST_SERVICE)
//time the function gets is in seconds, 60s = 1 minutes, 1 hour = 3600
//will be repeated every 10 minutes
.setTrigger(Trigger.executionWindow(/*600, 720*/1, 29))
//will be retried if it fails.
.setRecurring(true)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.setConstraints(
// only run on network
Constraint.ON_ANY_NETWORK
)
//if device is rebooted the job will be restarted
.setLifetime(Lifetime.FOREVER)
.build();
dispatcher.mustSchedule(job);
Log.d("AGNDDR-NotifiUpdate", "Job agendado para atualizar lista de coisas");
presenter.createServiceLocalNotificationsList();
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(intent);
finish();
......
......@@ -35,6 +35,7 @@ import br.ufpr.c3sl.agendador.agendador.models.AccountOutput;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
import br.ufpr.c3sl.agendador.agendador.network.ApiUtils;
import br.ufpr.c3sl.agendador.agendador.services.ImageUpdateService;
import br.ufpr.c3sl.agendador.agendador.services.notification.NotificationsListService;
import br.ufpr.c3sl.agendador.agendador.views.LoginView;
import okhttp3.Headers;
import okhttp3.ResponseBody;
......@@ -172,7 +173,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(580, 610))
.setTrigger(Trigger.executionWindow(60, 3600))
//will be retried if it fails.
.setRecurring(true)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
......@@ -194,6 +195,34 @@ public class LoginPresenter extends BasePresenter<LoginView> {
}
public void createServiceLocalNotificationsList(){
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(
new GooglePlayDriver(context)
);
Job job = dispatcher.newJobBuilder()
.setService(NotificationsListService.class)
.setTag(Utils.NOTIFICATION_UPDATE_LIST_SERVICE)
//time the function gets is in seconds, 60s = 1 minutes, 1 hour = 3600
//will be repeated every 10 minutes
.setTrigger(Trigger.executionWindow(570, 610))
//will be retried if it fails.
.setRecurring(true)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.setConstraints(
// only run on network
Constraint.ON_ANY_NETWORK
)
//if device is rebooted the job will be restarted
.setLifetime(Lifetime.FOREVER)
.build();
dispatcher.mustSchedule(job);
}
// TODO: 03/05/17 Adapt function to scenario with different file extensions, if needed.
private void checkLocalPhoto(){
......
......@@ -161,7 +161,6 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
Job job = dispatcher.newJobBuilder()
.setService(NotificationCreateService.class)
.setTag(Utils.NOTIFICATION_SERVICE + notification.scheduleId)
//time the function gets is in seconds, 60s = 1 minutes, 1 hour = 3600
.setTrigger(Trigger.NOW)
//will be retried if it fails.
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
......
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