mirror of
https://github.com/bspeice/UNCCGameDay
synced 2024-11-05 07:38:13 -05:00
Further Alert cleanup >AGK
This commit is contained in:
parent
7dc2e52a05
commit
33afb534bd
@ -1,10 +1,7 @@
|
|||||||
package com.uncc.gameday.alerts;
|
package com.uncc.gameday.alerts;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.uncc.gameday.R;
|
import com.uncc.gameday.R;
|
||||||
import com.uncc.gameday.activities.Home;
|
import com.uncc.gameday.activities.Home;
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -13,72 +10,72 @@ import android.support.v4.app.NotificationCompat;
|
|||||||
import android.support.v4.app.TaskStackBuilder;
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
|
|
||||||
public class Alert {
|
public class Alert {
|
||||||
|
|
||||||
private Date alarmDate;
|
private Long alarmDate;
|
||||||
private String message;
|
private String message;
|
||||||
private int shown;
|
private int shown;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
public Alert(){}
|
public Alert(){}
|
||||||
|
|
||||||
public Alert(Date alarmDate, String message, int shown, String type) {
|
public Alert(Long alarmDate, String message, int shown, String type) {
|
||||||
this.setAlarmDate(alarmDate);
|
this.setAlarmDate(alarmDate);
|
||||||
this.setMessage(message);
|
this.setMessage(message);
|
||||||
this.setShown(shown);
|
this.setShown(shown);
|
||||||
this.setType(type);
|
this.setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setType(String type) {
|
private void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
public Date getAlarmDate() {
|
public Long getAlarmDate() {
|
||||||
return alarmDate;
|
return alarmDate;
|
||||||
}
|
}
|
||||||
public void setAlarmDate(Date alarmDate) {
|
public void setAlarmDate(Long alarmDate) {
|
||||||
this.alarmDate = alarmDate;
|
this.alarmDate = alarmDate;
|
||||||
}
|
}
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
public int isShown() {
|
public int isShown() {
|
||||||
return shown;
|
return shown;
|
||||||
}
|
}
|
||||||
public void setShown(int i) {
|
public void setShown(int i) {
|
||||||
this.shown = i;
|
this.shown = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.message;
|
return this.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to make displaying an alert on the statusbar easy
|
* Helper method to make displaying an alert on the statusbar easy
|
||||||
*
|
*
|
||||||
* @param ctx - The context needed to display the alert.
|
* @param ctx - The context needed to display the alert.
|
||||||
*/
|
*/
|
||||||
public void displayNotification(Context ctx) {
|
public void displayNotification(Context ctx) {
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx)
|
||||||
.setSmallIcon(R.drawable.ic_launcher)
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
.setContentTitle(ctx.getString(R.string.app_name))
|
.setContentTitle(ctx.getString(R.string.app_name))
|
||||||
.setContentText(this.getMessage());
|
.setContentText(this.getMessage());
|
||||||
|
|
||||||
Intent resultIntent = new Intent(ctx, Home.class);
|
Intent resultIntent = new Intent(ctx, Home.class);
|
||||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx);
|
TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx);
|
||||||
stackBuilder.addParentStack(Home.class);
|
stackBuilder.addParentStack(Home.class);
|
||||||
stackBuilder.addNextIntent(resultIntent);
|
stackBuilder.addNextIntent(resultIntent);
|
||||||
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
builder.setContentIntent(resultPendingIntent);
|
builder.setContentIntent(resultPendingIntent);
|
||||||
|
|
||||||
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
notificationManager.notify(0, builder.setAutoCancel(true).build());
|
notificationManager.notify(0, builder.setAutoCancel(true).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user