Search in sources :

Example 6 with MonETSNotification

use of ca.etsmtl.applets.etsmobile.model.MonETSNotification in project ETSMobile-Android2 by ApplETS.

the class NotificationsAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    ViewHolder holder;
    if (view != null) {
        holder = (ViewHolder) view.getTag();
    } else {
        holder = new ViewHolder();
        view = inflater.inflate(R.layout.row_notification, parent, false);
        holder.tvNomApplication = (TextView) view.findViewById(R.id.tv_notif_application_name);
        holder.tvTexteNotification = (TextView) view.findViewById(R.id.tv_notif_text);
        holder.linearLayoutNotification = (LinearLayout) view.findViewById(R.id.linearLayout_notif);
        view.setTag(holder);
    }
    MonETSNotification item = getItem(position);
    String nomApplication = item.getNotificationApplicationNom();
    int colour = Utility.stringToColour(nomApplication, 60);
    holder.tvNomApplication.setText(nomApplication);
    holder.tvTexteNotification.setText(item.getNotificationTexte());
    holder.linearLayoutNotification.setBackgroundColor(colour);
    return view;
}
Also used : MonETSNotification(ca.etsmtl.applets.etsmobile.model.MonETSNotification)

Example 7 with MonETSNotification

use of ca.etsmtl.applets.etsmobile.model.MonETSNotification in project ETSMobile-Android2 by ApplETS.

the class ETSFcmListenerService method getMonETSNotificationFromMap.

public MonETSNotification getMonETSNotificationFromMap(Map<String, String> data) {
    int id = Integer.valueOf(data.get("Id"));
    String notificationTexte = data.get("NotificationTexte");
    String notificationApplicationNom = data.get("NotificationApplicationNom");
    // String notificationSigleCours = data.getString("NotificationSigleCours");
    String url = data.get("Url");
    return new MonETSNotification(id, 0, notificationTexte, null, notificationApplicationNom, url);
}
Also used : MonETSNotification(ca.etsmtl.applets.etsmobile.model.MonETSNotification) SpannableString(android.text.SpannableString)

Example 8 with MonETSNotification

use of ca.etsmtl.applets.etsmobile.model.MonETSNotification in project ETSMobile-Android2 by ApplETS.

the class NotificationManager method updateDatabase.

/**
 * Updates the database with a given list of notifications
 *
 * @param notifications the list of notifications that have been fetched from MonÉTS's API
 */
private void updateDatabase(List<MonETSNotification> notifications) {
    DatabaseHelper databaseHelper = new DatabaseHelper(context);
    try {
        Dao<MonETSNotification, ?> dao = databaseHelper.getDao(MonETSNotification.class);
        for (MonETSNotification monETSNotification : notifications) {
            dao.createOrUpdate(monETSNotification);
        }
        listener.onRequestSuccess(notifications);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
Also used : MonETSNotification(ca.etsmtl.applets.etsmobile.model.MonETSNotification) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException)

Aggregations

MonETSNotification (ca.etsmtl.applets.etsmobile.model.MonETSNotification)8 SpannableString (android.text.SpannableString)4 SecurePreferences (ca.etsmtl.applets.etsmobile.util.SecurePreferences)3 NotificationManager (android.app.NotificationManager)2 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Spannable (android.text.Spannable)2 StyleSpan (android.text.style.StyleSpan)2 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)2 DataManager (ca.etsmtl.applets.etsmobile.http.DataManager)2 Gson (com.google.gson.Gson)2 TypeToken (com.google.gson.reflect.TypeToken)2 SQLException (java.sql.SQLException)2 NotificationChannel (android.app.NotificationChannel)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 NotificationCompat (androidx.core.app.NotificationCompat)1 MonETSNotificationsRequest (ca.etsmtl.applets.etsmobile.http.MonETSNotificationsRequest)1 MonETSNotificationList (ca.etsmtl.applets.etsmobile.model.MonETSNotificationList)1 NotificationsAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.NotificationsAdapter)1