use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class DashboardUnsentFragment method reloadSurveys.
public void reloadSurveys(List<Survey> newListSurveys) {
Log.d(TAG, "reloadSurveys (Thread: " + Thread.currentThread().getId() + "): " + newListSurveys.size());
this.surveys.clear();
for (Survey survey : newListSurveys) {
if (!survey.isStockSurvey()) {
this.surveys.add(survey);
}
}
this.adapter.notifyDataSetChanged();
if (viewCreated) {
LayoutUtils.measureListViewHeightBasedOnChildren(getListView());
setListShown(true);
}
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class MonitorService method prepareMonitorData.
private void prepareMonitorData() {
Log.i(TAG, "Preparing monitor data...");
//Take last 6 months sent surveys in order to create monitor stats on top of them.
List<Survey> sentSurveysForMonitor = Survey.findSentSurveysAfterDate(TimePeriodCalculator.getInstance().getMinDateForMonitor());
Log.i(TAG, String.format("Found %d surveys to build monitor info, aggregating data...", sentSurveysForMonitor.size()));
MonitorBuilder monitorBuilder = new MonitorBuilder(getApplicationContext());
monitorBuilder.addSurveys(sentSurveysForMonitor);
//Since intents does NOT admit NON serializable as values we use Session instead
Log.i(TAG, String.format("Monitor data calculated ok", sentSurveysForMonitor.size()));
Session.putServiceValue(PREPARE_MONITOR_DATA, monitorBuilder);
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(PREPARE_MONITOR_DATA));
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class SurveyService method getAllUncompletedSurveys.
private void getAllUncompletedSurveys() {
Log.d(TAG, "getAllUncompletedSurveys (Thread:" + Thread.currentThread().getId() + ")");
//Select surveys from sql
List<Survey> surveys = Survey.getAllUncompletedSurveys();
//Load %completion in every survey (it takes a while so it can NOT be done in UI Thread)
for (Survey survey : surveys) {
survey.getAnsweredQuestionRatio();
}
//Since intents does NOT admit NON serializable as values we use Session instead
Session.putServiceValue(ALL_UNCOMPLETED_SURVEYS_ACTION, surveys);
//Returning result to anyone listening
Intent resultIntent = new Intent(ALL_UNCOMPLETED_SURVEYS_ACTION);
LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class SurveyService method getAllCompletedSurveys.
private void getAllCompletedSurveys() {
Log.d(TAG, "getAllCompletedSurveys (Thread:" + Thread.currentThread().getId() + ")");
//Select surveys from sql
List<Survey> surveys = Survey.getAllCompletedSurveys();
//Load %completion in every survey (it takes a while so it can NOT be done in UI Thread)
for (Survey survey : surveys) {
survey.getAnsweredQuestionRatio();
}
//Since intents does NOT admit NON serializable as values we use Session instead
Session.putServiceValue(ALL_SENT_SURVEYS_ACTION, surveys);
//Returning result to anyone listening
Intent resultIntent = new Intent(ALL_SENT_SURVEYS_ACTION);
LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class SurveyService method getAllSentSurveys.
/**
* Selects all sent surveys from database
*/
private void getAllSentSurveys() {
Log.d(TAG, "getAllSentMalariaSurveys (Thread:" + Thread.currentThread().getId() + ")");
//Select surveys from sql
List<Survey> surveys = Survey.getAllSentMalariaSurveys();
//Since intents does NOT admit NON serializable as values we use Session instead
Session.putServiceValue(ALL_SENT_SURVEYS_ACTION, surveys);
//Returning result to anyone listening
Intent resultIntent = new Intent(ALL_SENT_SURVEYS_ACTION);
LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
Aggregations