Search in sources :

Example 6 with Alert

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();
}
Also used : Alert(com.giua.objects.Alert) LinearLayout(android.widget.LinearLayout)

Example 7 with Alert

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;
}
Also used : Alert(com.giua.objects.Alert) Cursor(android.database.Cursor) Vector(java.util.Vector)

Example 8 with Alert

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;
}
Also used : Alert(com.giua.objects.Alert) Cursor(android.database.Cursor) Vector(java.util.Vector)

Example 9 with Alert

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();
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Alert(com.giua.objects.Alert)

Example 10 with Alert

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Alert(com.giua.objects.Alert) Cursor(android.database.Cursor) Vector(java.util.Vector)

Aggregations

Alert (com.giua.objects.Alert)18 Vector (java.util.Vector)11 Cursor (android.database.Cursor)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 LinearLayout (android.widget.LinearLayout)3 IOException (java.io.IOException)3 TextView (android.widget.TextView)2 GiuaScraperExceptions (com.giua.webscraper.GiuaScraperExceptions)2 URISyntaxException (java.net.URISyntaxException)2 ParseException (java.text.ParseException)2 Document (org.jsoup.nodes.Document)2 Element (org.jsoup.nodes.Element)2 Elements (org.jsoup.select.Elements)2 Notification (android.app.Notification)1 AlertsPage (com.giua.pages.AlertsPage)1 JsonBuilder (com.giua.utils.JsonBuilder)1 JsonParser (com.giua.utils.JsonParser)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1