@Test public void testBuildNotification() { mNotification.parseMessageData(); Notification notification = mNotification.buildNotification(mContext, null); assertNotNull(notification); long scheduledStartTimeUNIX = mNotification.getMatchTime().getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(mContext); String startTime = format.format(scheduledStartTime); StoredNotification stored = mNotification.getStoredNotification(); assertNotNull(stored); assertEquals(stored.getType(), NotificationTypes.SCHEDULE_UPDATED); assertEquals(stored.getTitle(), mContext.getString(R.string.notification_schedule_updated_title, "AUSY")); assertEquals(stored.getBody(), mContext.getString(R.string.notification_schedule_updated_with_time, "Australia", startTime)); assertEquals(stored.getMessageData(), mData.toString()); assertEquals(stored.getIntent(), MyTBAHelper.serializeIntent(mNotification.getIntent(mContext))); assertNotNull(stored.getTime()); }
@Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { String firstMatchTime = null; if (!JSONHelper.isNull(matchTime)) { Date date = new Date(matchTime.getAsLong() * 1000L); java.text.DateFormat format = DateFormat.getTimeFormat(context); firstMatchTime = format.format(date); } String eventShortName = EventHelper.shortName(eventName); String contentText; if (firstMatchTime == null) { contentText = context.getString(R.string.notification_schedule_updated_without_time, eventShortName); } else { contentText = context.getString(R.string.notification_schedule_updated_with_time, eventShortName, firstMatchTime); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = context.getString(R.string.notification_schedule_updated_title, eventCode); stored.setTitle(title); stored.setBody(contentText); stored.setMessageData(messageData); stored.setIntent(MyTBAHelper.serializeIntent(instance)); stored.setTime(Calendar.getInstance().getTime()); stored.setSystemId(getNotificationId()); NotificationCompat.Builder builder = getBaseBuilder(context, instance) .setContentTitle(title) .setContentText(contentText); NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(contentText); builder.setStyle(style); return builder.build(); }
ScheduleUpdatedNotification extends BaseNotification<ScheduleUpdatedNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { String firstMatchTime = null; if (!JSONHelper.isNull(matchTime)) { Date date = new Date(matchTime.getAsLong() * 1000L); java.text.DateFormat format = DateFormat.getTimeFormat(context); firstMatchTime = format.format(date); } String eventShortName = EventHelper.shortName(eventName); String contentText; if (firstMatchTime == null) { contentText = context.getString(R.string.notification_schedule_updated_without_time, eventShortName); } else { contentText = context.getString(R.string.notification_schedule_updated_with_time, eventShortName, firstMatchTime); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = context.getString(R.string.notification_schedule_updated_title, eventCode); stored.setTitle(title); stored.setBody(contentText); stored.setMessageData(messageData); stored.setIntent(MyTBAHelper.serializeIntent(instance)); stored.setTime(Calendar.getInstance().getTime()); stored.setSystemId(getNotificationId()); NotificationCompat.Builder builder = getBaseBuilder(context, instance) .setContentTitle(title) .setContentText(contentText); NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(contentText); builder.setStyle(style); return builder.build(); } }
ScheduleUpdatedNotification extends BaseNotification<ScheduleUpdatedNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { String firstMatchTime = null; if (!JSONHelper.isNull(matchTime)) { Date date = new Date(matchTime.getAsLong() * 1000L); java.text.DateFormat format = DateFormat.getTimeFormat(context); firstMatchTime = format.format(date); } String eventShortName = EventHelper.shortName(eventName); String contentText; if (firstMatchTime == null) { contentText = context.getString(R.string.notification_schedule_updated_without_time, eventShortName); } else { contentText = context.getString(R.string.notification_schedule_updated_with_time, eventShortName, firstMatchTime); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = context.getString(R.string.notification_schedule_updated_title, eventCode); stored.setTitle(title); stored.setBody(contentText); stored.setMessageData(messageData); stored.setIntent(MyTBAHelper.serializeIntent(instance)); stored.setTime(Calendar.getInstance().getTime()); stored.setSystemId(getNotificationId()); NotificationCompat.Builder builder = getBaseBuilder(context, instance) .setContentTitle(title) .setContentText(contentText); NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(contentText); builder.setStyle(style); return builder.build(); } ScheduleUpdatedNotification(String messageData); }
ScheduleUpdatedNotification extends BaseNotification<ScheduleUpdatedNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { String firstMatchTime = null; if (!JSONHelper.isNull(matchTime)) { Date date = new Date(matchTime.getAsLong() * 1000L); java.text.DateFormat format = DateFormat.getTimeFormat(context); firstMatchTime = format.format(date); } String eventShortName = EventHelper.shortName(eventName); String contentText; if (firstMatchTime == null) { contentText = context.getString(R.string.notification_schedule_updated_without_time, eventShortName); } else { contentText = context.getString(R.string.notification_schedule_updated_with_time, eventShortName, firstMatchTime); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = context.getString(R.string.notification_schedule_updated_title, eventCode); stored.setTitle(title); stored.setBody(contentText); stored.setMessageData(messageData); stored.setIntent(MyTBAHelper.serializeIntent(instance)); stored.setTime(Calendar.getInstance().getTime()); stored.setSystemId(getNotificationId()); NotificationCompat.Builder builder = getBaseBuilder(context, instance) .setContentTitle(title) .setContentText(contentText); NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(contentText); builder.setStyle(style); return builder.build(); } ScheduleUpdatedNotification(String messageData); String getEventName(); String getEventKey(); JsonElement getMatchTime(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override void updateDataLocally(); @Override Intent getIntent(Context c); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override ScheduleUpdatedNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid); }
ScheduleUpdatedNotification extends BaseNotification<ScheduleUpdatedNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { String firstMatchTime = null; if (!JSONHelper.isNull(matchTime)) { Date date = new Date(matchTime.getAsLong() * 1000L); java.text.DateFormat format = DateFormat.getTimeFormat(context); firstMatchTime = format.format(date); } String eventShortName = EventHelper.shortName(eventName); String contentText; if (firstMatchTime == null) { contentText = context.getString(R.string.notification_schedule_updated_without_time, eventShortName); } else { contentText = context.getString(R.string.notification_schedule_updated_with_time, eventShortName, firstMatchTime); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = context.getString(R.string.notification_schedule_updated_title, eventCode); stored.setTitle(title); stored.setBody(contentText); stored.setMessageData(messageData); stored.setIntent(MyTBAHelper.serializeIntent(instance)); stored.setTime(Calendar.getInstance().getTime()); stored.setSystemId(getNotificationId()); NotificationCompat.Builder builder = getBaseBuilder(context, instance) .setContentTitle(title) .setContentText(contentText); NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(contentText); builder.setStyle(style); return builder.build(); } ScheduleUpdatedNotification(String messageData); String getEventName(); String getEventKey(); JsonElement getMatchTime(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override void updateDataLocally(); @Override Intent getIntent(Context c); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override ScheduleUpdatedNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid);  }