Added notification for errors and warnings

This commit is contained in:
2015-10-29 16:38:50 +01:00
parent 2a17bbe34b
commit e98eefe2cc
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package ch.dissem.apps.abit.notification;
import android.content.Context;
import android.support.v7.app.NotificationCompat;
import ch.dissem.apps.abit.R;
/**
* Created by chrigu on 29.10.15.
*/
public class ErrorNotification extends AbstractNotification {
public static final int ERROR_NOTIFICATION_ID = 4;
private NotificationCompat.Builder builder;
public ErrorNotification(Context ctx) {
super(ctx);
builder = new NotificationCompat.Builder(ctx);
builder.setContentTitle(ctx.getString(R.string.app_name))
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
}
public ErrorNotification setWarning(int resId, Object... args) {
builder.setSmallIcon(R.drawable.ic_notification_warning)
.setContentText(ctx.getString(resId, args));
notification = builder.build();
return this;
}
public ErrorNotification setError(int resId, Object... args) {
builder.setSmallIcon(R.drawable.ic_notification_error)
.setContentText(ctx.getString(resId, args));
notification = builder.build();
return this;
}
@Override
protected int getNotificationId() {
return ERROR_NOTIFICATION_ID;
}
}