Search in sources :

Example 1 with GpodnetServiceAuthenticationException

use of de.danoeh.antennapod.core.gpoddernet.GpodnetServiceAuthenticationException in project AntennaPod by AntennaPod.

the class GpodnetSyncService method updateErrorNotification.

private void updateErrorNotification(GpodnetServiceException exception) {
    Log.d(TAG, "Posting error notification");
    GpodnetPreferences.setLastSyncAttempt(false, System.currentTimeMillis());
    final String title;
    final String description;
    final int id;
    if (exception instanceof GpodnetServiceAuthenticationException) {
        title = getString(R.string.gpodnetsync_auth_error_title);
        description = getString(R.string.gpodnetsync_auth_error_descr);
        id = R.id.notification_gpodnet_sync_autherror;
    } else {
        if (UserPreferences.gpodnetNotificationsEnabled()) {
            title = getString(R.string.gpodnetsync_error_title);
            description = getString(R.string.gpodnetsync_error_descr) + exception.getMessage();
            id = R.id.notification_gpodnet_sync_error;
        } else {
            return;
        }
    }
    PendingIntent activityIntent = ClientConfig.gpodnetCallbacks.getGpodnetSyncServiceErrorNotificationPendingIntent(this);
    Notification notification = new NotificationCompat.Builder(this).setContentTitle(title).setContentText(description).setContentIntent(activityIntent).setSmallIcon(R.drawable.stat_notify_sync_error).setAutoCancel(true).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(id, notification);
}
Also used : GpodnetServiceAuthenticationException(de.danoeh.antennapod.core.gpoddernet.GpodnetServiceAuthenticationException) NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Aggregations

Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 GpodnetServiceAuthenticationException (de.danoeh.antennapod.core.gpoddernet.GpodnetServiceAuthenticationException)1