@Test public void testBuildNotification() { mNotification.parseMessageData(); Notification notification = mNotification.buildNotification(mContext, null); assertNotNull(notification); long scheduledStartTimeUNIX = mNotification.getScheduledTime().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(NotificationTypes.LEVEL_STARTING, stored.getType()); assertEquals(mContext.getString(R.string.notification_level_starting_title, "HIHO", "Finals Matches"), stored.getTitle()); assertEquals(mContext.getString(R.string.notification_level_starting_with_time, mNotification.getEventName(), "Finals Matches", startTime), stored.getBody()); assertEquals(mData.toString(), stored.getMessageData()); assertEquals(MyTBAHelper.serializeIntent(mNotification.getIntent(mContext)), stored.getIntent()); assertNotNull(stored.getTime()); }
@Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { Resources r = context.getResources(); String compLevel = getCompLevelNameFromAbbreviation(context, compLevelAbbrev); String scheduledStartTimeString = ""; if (!JSONHelper.isNull(scheduledTime)) { long scheduledStartTimeUNIX = scheduledTime.getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(context); scheduledStartTimeString = format.format(scheduledStartTime); } String contentText; if (scheduledStartTimeString.isEmpty()) { contentText = r.getString(R.string.notification_level_starting, eventName, compLevel); } else { contentText = r.getString(R.string.notification_level_starting_with_time, eventName, compLevel, scheduledStartTimeString); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = r.getString(R.string.notification_level_starting_title, eventCode, compLevel); 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(); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { Resources r = context.getResources(); String compLevel = getCompLevelNameFromAbbreviation(context, compLevelAbbrev); String scheduledStartTimeString = ""; if (!JSONHelper.isNull(scheduledTime)) { long scheduledStartTimeUNIX = scheduledTime.getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(context); scheduledStartTimeString = format.format(scheduledStartTime); } String contentText; if (scheduledStartTimeString.isEmpty()) { contentText = r.getString(R.string.notification_level_starting, eventName, compLevel); } else { contentText = r.getString(R.string.notification_level_starting_with_time, eventName, compLevel, scheduledStartTimeString); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = r.getString(R.string.notification_level_starting_title, eventCode, compLevel); 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(); } }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { Resources r = context.getResources(); String compLevel = getCompLevelNameFromAbbreviation(context, compLevelAbbrev); String scheduledStartTimeString = ""; if (!JSONHelper.isNull(scheduledTime)) { long scheduledStartTimeUNIX = scheduledTime.getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(context); scheduledStartTimeString = format.format(scheduledStartTime); } String contentText; if (scheduledStartTimeString.isEmpty()) { contentText = r.getString(R.string.notification_level_starting, eventName, compLevel); } else { contentText = r.getString(R.string.notification_level_starting_with_time, eventName, compLevel, scheduledStartTimeString); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = r.getString(R.string.notification_level_starting_title, eventCode, compLevel); 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(); } CompLevelStartingNotification(String messageData); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { Resources r = context.getResources(); String compLevel = getCompLevelNameFromAbbreviation(context, compLevelAbbrev); String scheduledStartTimeString = ""; if (!JSONHelper.isNull(scheduledTime)) { long scheduledStartTimeUNIX = scheduledTime.getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(context); scheduledStartTimeString = format.format(scheduledStartTime); } String contentText; if (scheduledStartTimeString.isEmpty()) { contentText = r.getString(R.string.notification_level_starting, eventName, compLevel); } else { contentText = r.getString(R.string.notification_level_starting_with_time, eventName, compLevel, scheduledStartTimeString); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = r.getString(R.string.notification_level_starting_title, eventCode, compLevel); 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(); } CompLevelStartingNotification(String messageData); @Nullable JsonElement getScheduledTime(); String getEventName(); String getEventKey(); String getCompLevelAbbrev(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override Intent getIntent(Context c); @Override void updateDataLocally(); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override CompLevelStartingNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public Notification buildNotification(Context context, FollowsChecker followsChecker) { Resources r = context.getResources(); String compLevel = getCompLevelNameFromAbbreviation(context, compLevelAbbrev); String scheduledStartTimeString = ""; if (!JSONHelper.isNull(scheduledTime)) { long scheduledStartTimeUNIX = scheduledTime.getAsLong(); Date scheduledStartTime = new Date(scheduledStartTimeUNIX * 1000); DateFormat format = android.text.format.DateFormat.getTimeFormat(context); scheduledStartTimeString = format.format(scheduledStartTime); } String contentText; if (scheduledStartTimeString.isEmpty()) { contentText = r.getString(R.string.notification_level_starting, eventName, compLevel); } else { contentText = r.getString(R.string.notification_level_starting_with_time, eventName, compLevel, scheduledStartTimeString); } Intent instance = getIntent(context); stored = new StoredNotification(); stored.setType(getNotificationType()); String eventCode = EventHelper.getEventCode(eventKey); String title = r.getString(R.string.notification_level_starting_title, eventCode, compLevel); 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(); } CompLevelStartingNotification(String messageData); @Nullable JsonElement getScheduledTime(); String getEventName(); String getEventKey(); String getCompLevelAbbrev(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override Intent getIntent(Context c); @Override void updateDataLocally(); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override CompLevelStartingNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid);  }