use of com.thebluealliance.androidclient.models.StoredNotification in project the-blue-alliance-android by the-blue-alliance.
the class RecentNotificationsSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
for (int i = 0; i < mAPIData.size(); i++) {
StoredNotification notification = mAPIData.get(i);
BaseNotification renderable = notification.getNotification(mWriter, mMatchRenderer, mGson);
if (renderable != null) {
renderable.parseMessageData();
Object viewModel = renderable.renderToViewModel(mContext, null);
if (viewModel == null) {
TbaLogger.w("Attempt to bind to a null ViewModel from " + notification.getType());
} else {
mDataToBind.add(viewModel);
}
}
}
}
use of com.thebluealliance.androidclient.models.StoredNotification in project the-blue-alliance-android by the-blue-alliance.
the class NotificationsTable method getActive.
public List<StoredNotification> getActive() {
ArrayList<StoredNotification> out = new ArrayList<>();
Cursor cursor = mDb.query(Database.TABLE_NOTIFICATIONS, null, ACTIVE + " = 1", null, null, null, ID + " DESC", null);
if (cursor != null && cursor.moveToFirst()) {
do {
out.add(ModelInflater.inflateStoredNotification(cursor));
} while (cursor.moveToNext());
cursor.close();
}
return out;
}
use of com.thebluealliance.androidclient.models.StoredNotification in project the-blue-alliance-android by the-blue-alliance.
the class EventMatchVideoNotification method buildNotification.
@Override
public Notification buildNotification(Context context, FollowsChecker followsChecker) {
Resources r = context.getResources();
String eventCode = EventHelper.getEventCode(eventKey);
String title = r.getString(R.string.notification_event_match_video, eventCode);
String notificationBody = r.getString(R.string.notification_event_match_video_content, EventHelper.shortName(eventName));
// We can finally build the notification!
Intent instance = getIntent(context);
stored = new StoredNotification();
stored.setType(getNotificationType());
stored.setTitle(title);
stored.setBody(notificationBody);
stored.setIntent(MyTBAHelper.serializeIntent(instance));
stored.setTime(Calendar.getInstance().getTime());
stored.setMessageData(messageData);
stored.setSystemId(getNotificationId());
NotificationCompat.Builder builder = getBaseBuilder(context, instance).setOnlyAlertOnce(true).setContentTitle(title).setContentText(notificationBody);
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(notificationBody);
builder.setStyle(style);
return builder.build();
}
use of com.thebluealliance.androidclient.models.StoredNotification in project the-blue-alliance-android by the-blue-alliance.
the class GenericNotification method buildNotification.
@Override
public Notification buildNotification(Context context, FollowsChecker followsChecker) {
stored = new StoredNotification();
stored.setType(getNotificationType());
stored.setTitle(title);
stored.setBody(message);
stored.setMessageData(messageData);
stored.setTime(Calendar.getInstance().getTime());
stored.setSystemId(getNotificationId());
Intent intent = getIntent(context);
NotificationCompat.Builder builder = getBaseBuilder(context, intent).setContentTitle(title).setContentText(message).setStyle(new NotificationCompat.BigTextStyle().bigText(message));
return builder.build();
}
use of com.thebluealliance.androidclient.models.StoredNotification in project the-blue-alliance-android by the-blue-alliance.
the class ScoreNotification method buildNotification.
@Override
public Notification buildNotification(Context context, FollowsChecker followsChecker) {
Resources r = context.getResources();
matchKey = match.getKey();
String matchTitle = MatchHelper.getMatchTitleFromMatchKey(context, matchKey);
String matchAbbrevTitle = MatchHelper.getAbbrevMatchTitleFromMatchKey(context, matchKey);
IMatchAlliancesContainer alliances = match.getAlliances();
int redScore = Match.getRedScore(alliances);
int blueScore = Match.getBlueScore(alliances);
// Boldify the team numbers that the user is following, but only if the system supports
// java 8 language features
CharSequence firstTeams;
CharSequence secondTeams;
ArrayList<String> redTeams = Match.teamNumbers(Match.getRedTeams(alliances));
ArrayList<String> blueTeams = Match.teamNumbers(Match.getBlueTeams(alliances));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
Predicate<String> isFollowing = teamNumber -> followsChecker.followsTeam(context, teamNumber, matchKey, NotificationTypes.MATCH_SCORE);
firstTeams = Utilities.boldNameList(redTeams, isFollowing);
secondTeams = Utilities.boldNameList(blueTeams, isFollowing);
} else {
firstTeams = Utilities.stringifyListOfStrings(context, redTeams);
secondTeams = Utilities.stringifyListOfStrings(context, blueTeams);
}
// Make sure the score string is formatted properly with the winning score first
String scoreString;
if (blueScore > redScore) {
scoreString = blueScore + "-" + redScore;
CharSequence temp = firstTeams;
firstTeams = secondTeams;
secondTeams = temp;
} else {
scoreString = redScore + "-" + blueScore;
}
MatchType matchType = MatchType.fromShortType(match.getCompLevel());
boolean useSpecial2015Format = match.getYear() == 2015 && matchType != MatchType.FINAL;
String eventShortName = EventHelper.shortName(eventName);
String template;
if (useSpecial2015Format) {
// firstTeams played secondTeams (for 2015 non-finals matches)
template = context.getString(R.string.notification_score_teams_played_teams);
} else if (blueScore == redScore) {
// firstTeams tied secondTeams
template = context.getString(R.string.notification_score_teams_tied_teams);
} else {
// firstTeams beat secondTeams
template = context.getString(R.string.notification_score_teams_beat_teams);
}
CharSequence notificationBody = TextUtils.expandTemplate(template, eventShortName, matchTitle, firstTeams, secondTeams, scoreString);
// We can finally build the notification!
Intent instance = getIntent(context);
stored = new StoredNotification();
stored.setType(getNotificationType());
String eventCode = EventHelper.getEventCode(matchKey);
String notificationTitle = r.getString(R.string.notification_score_title, eventCode, matchAbbrevTitle);
stored.setTitle(notificationTitle);
stored.setBody(notificationBody.toString());
stored.setIntent(MyTBAHelper.serializeIntent(instance));
stored.setTime(Calendar.getInstance().getTime());
stored.setMessageData(messageData);
stored.setSystemId(getNotificationId());
NotificationCompat.Builder builder = getBaseBuilder(context, instance).setContentTitle(notificationTitle).setContentText(notificationBody);
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(notificationBody);
builder.setStyle(style);
return builder.build();
}
Aggregations