use of com.giua.objects.Alert in project Giua-App by Giua-app.
the class AlertsFragment method addViews.
/**
* Aggiunge effetivamente le {@code AlertView}
*/
@Override
public void addViews() {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 40, 0, 0);
for (Alert alert : allAlerts) {
AlertView view = new AlertView(requireActivity(), null, alert);
view.setLayoutParams(params);
view.setId(View.generateViewId());
view.setOnClickListener(this::alertViewOnClick);
viewsLayout.addView(view);
}
finishedLoading();
}
use of com.giua.objects.Alert in project Giua-App by Giua-app.
the class NotificationsDBController method readAlertsTests.
public List<Alert> readAlertsTests() {
Cursor cursor = db.rawQuery("SELECT * FROM " + ALERTS_TESTS_TABLE, null);
List<Alert> alerts = new Vector<>();
if (cursor.moveToFirst()) {
do {
// 0 = false, 1 = true
boolean isDetailed = cursor.getInt(DBAlertTests.IS_DETAILED_COL.ordinal()) != 0;
if (isDetailed) {
List<String> attachmentUrls = null;
try {
attachmentUrls = Arrays.asList(cursor.getString(DBAlertTests.ATTACHMENT_URLS_COL.ordinal()).split(";"));
} catch (NullPointerException ignored) {
}
alerts.add(new Alert(cursor.getString(DBAlertTests.STATUS_COL.ordinal()), cursor.getString(DBAlertTests.DATE_COL.ordinal()), cursor.getString(DBAlertTests.RECEIVERS_COL.ordinal()), cursor.getString(DBAlertTests.OBJECT_COL.ordinal()), cursor.getString(DBAlertTests.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlertTests.PAGE_COL.ordinal()), attachmentUrls, cursor.getString(DBAlertTests.DETAILS_COL.ordinal()), cursor.getString(DBAlertTests.CREATOR_COL.ordinal()), cursor.getString(DBAlertTests.TYPE_COL.ordinal())));
} else {
alerts.add(new Alert(cursor.getString(DBAlertTests.DATE_COL.ordinal()), cursor.getString(DBAlertTests.DATE_COL.ordinal()), cursor.getString(DBAlertTests.RECEIVERS_COL.ordinal()), cursor.getString(DBAlertTests.OBJECT_COL.ordinal()), cursor.getString(DBAlertTests.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlertTests.PAGE_COL.ordinal())));
}
} while (cursor.moveToNext());
// muovi il cursore nella prossima riga
}
cursor.close();
return alerts;
}
use of com.giua.objects.Alert in project Giua-App by Giua-app.
the class NotificationsDBController method readAlertsHomeworks.
public List<Alert> readAlertsHomeworks() {
Cursor cursor = db.rawQuery("SELECT * FROM " + ALERTS_HOMEWORKS_TABLE, null);
List<Alert> alerts = new Vector<>();
if (cursor.moveToFirst()) {
do {
// 0 = false, 1 = true
boolean isDetailed = cursor.getInt(DBAlertHomeworks.IS_DETAILED_COL.ordinal()) != 0;
if (isDetailed) {
List<String> attachmentUrls = null;
try {
attachmentUrls = Arrays.asList(cursor.getString(DBAlertHomeworks.ATTACHMENT_URLS_COL.ordinal()).split(";"));
} catch (NullPointerException ignored) {
}
alerts.add(new Alert(cursor.getString(DBAlertHomeworks.STATUS_COL.ordinal()), cursor.getString(DBAlertHomeworks.DATE_COL.ordinal()), cursor.getString(DBAlertHomeworks.RECEIVERS_COL.ordinal()), cursor.getString(DBAlertHomeworks.OBJECT_COL.ordinal()), cursor.getString(DBAlertHomeworks.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlertHomeworks.PAGE_COL.ordinal()), attachmentUrls, cursor.getString(DBAlertHomeworks.DETAILS_COL.ordinal()), cursor.getString(DBAlertHomeworks.CREATOR_COL.ordinal()), cursor.getString(DBAlertHomeworks.TYPE_COL.ordinal())));
} else {
alerts.add(new Alert(cursor.getString(DBAlertHomeworks.DATE_COL.ordinal()), cursor.getString(DBAlertHomeworks.DATE_COL.ordinal()), cursor.getString(DBAlertHomeworks.RECEIVERS_COL.ordinal()), cursor.getString(DBAlertHomeworks.OBJECT_COL.ordinal()), cursor.getString(DBAlertHomeworks.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlertHomeworks.PAGE_COL.ordinal())));
}
} while (cursor.moveToNext());
// muovi il cursore nella prossima riga
}
cursor.close();
return alerts;
}
use of com.giua.objects.Alert in project Giua-App by Giua-app.
the class OfflineDBController method addAlerts.
public void addAlerts(List<Alert> alerts) {
SQLiteDatabase db = getWritableDatabase();
for (Alert alert : alerts) {
addAlert(alert, db);
}
db.close();
}
use of com.giua.objects.Alert in project Giua-App by Giua-app.
the class OfflineDBController method readAlerts.
public List<Alert> readAlerts() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM " + ALERTS_TABLE + " ORDER BY " + DBAlert.ALERT_ID.name + " DESC", null);
List<Alert> alerts = new Vector<>();
if (cursor.moveToFirst()) {
do {
// 0 = false, 1 = true
boolean isDetailed = cursor.getInt(DBAlert.IS_DETAILED_COL.ordinal()) != 0;
if (isDetailed) {
List<String> attachmentUrls = null;
try {
attachmentUrls = Arrays.asList(cursor.getString(DBAlert.ATTACHMENT_URLS_COL.ordinal()).split(";"));
} catch (NullPointerException ignored) {
}
alerts.add(new Alert(cursor.getString(DBAlert.STATUS_COL.ordinal()), cursor.getString(DBAlert.DATE_COL.ordinal()), cursor.getString(DBAlert.RECEIVERS_COL.ordinal()), cursor.getString(DBAlert.OBJECT_COL.ordinal()), cursor.getString(DBAlert.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlert.PAGE_COL.ordinal()), attachmentUrls, cursor.getString(DBAlert.DETAILS_COL.ordinal()), cursor.getString(DBAlert.CREATOR_COL.ordinal()), cursor.getString(DBAlert.TYPE_COL.ordinal())));
} else {
alerts.add(new Alert(cursor.getString(DBAlert.DATE_COL.ordinal()), cursor.getString(DBAlert.DATE_COL.ordinal()), cursor.getString(DBAlert.RECEIVERS_COL.ordinal()), cursor.getString(DBAlert.OBJECT_COL.ordinal()), cursor.getString(DBAlert.DETAILS_URL_COL.ordinal()), cursor.getInt(DBAlert.PAGE_COL.ordinal())));
}
} while (cursor.moveToNext());
// muovi il cursore nella prossima riga
}
cursor.close();
return alerts;
}
Aggregations