public static void notifyTicket(Context c,@NonNull Ticket t,boolean keepNotification){
  String text;
  String ticker;
  int smallIcon;
  int largeIcon;
  int status;
switch (TicketsAdapter.getValidityStatus(t.getStatus(),t.getValidTo())) {
case TicketProvider.Tickets.STATUS_VALID:
case TicketProvider.Tickets.STATUS_VALID_EXPIRING:
    text=c.getString(R.string.notif_valid_text,FormatUtil.formatDateTimeDifference(t.getValidTo()));
  ticker=c.getString(R.string.notif_valid_ticker);
smallIcon=R.drawable.notification_small_ready;
largeIcon=R.drawable.notification_big_ready;
status=TicketProvider.Tickets.STATUS_VALID_EXPIRING;
break;
case TicketProvider.Tickets.STATUS_EXPIRING:
case TicketProvider.Tickets.STATUS_EXPIRING_EXPIRED:
text=c.getString(R.string.notif_expiring_text,FormatUtil.formatTime(t.getValidTo()));
ticker=c.getString(R.string.notif_expiring_ticker);
smallIcon=R.drawable.notification_small_warning;
largeIcon=R.drawable.notification_big_warning;
status=TicketProvider.Tickets.STATUS_EXPIRING_EXPIRED;
break;
case TicketProvider.Tickets.STATUS_EXPIRED:
text=c.getString(R.string.notif_expired_text,FormatUtil.formatTime(t.getValidTo()));
ticker=c.getString(R.string.notif_expired_ticker);
smallIcon=R.drawable.notification_small_expired;
largeIcon=R.drawable.notification_big_expired;
status=TicketProvider.Tickets.STATUS_EXPIRED;
break;
default :
return;
}
Intent intent=new Intent(c,WearableService.class);
intent.setAction("sent_notification_to_wear");
intent.putExtra("ticket",t);
intent.putExtra("status",status);
c.startService(intent);
Intent i=new Intent(c,MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra(MainActivity.EXTRA_TICKET_ID,t.getId());
PendingIntent openIntent=PendingIntent.getActivity(c,t.getNotificationId(),i,PendingIntent.FLAG_CANCEL_CURRENT);
Intent i2=new Intent(c,MainActivity.class);
i2.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
i2.putExtra(MainActivity.EXTRA_TICKET_ID,t.getId());
i2.putExtra(MainActivity.EXTRA_SHOW_SMS,true);
PendingIntent showSmsIntent=PendingIntent.getActivity(c,t.getNotificationId() + 1000,i2,PendingIntent.FLAG_CANCEL_CURRENT);
List<Action> actions=new ArrayList<Action>();
actions.add(new Action(R.drawable.notification_show_sms,R.string.notif_show_sms,showSmsIntent));
List<String> rows=new ArrayList<String>();
rows.add(text);
rows.add(c.getString(R.string.tickets_valid_from) + ": " + FormatUtil.formatDateTime(t.getValidFrom()));
rows.add(c.getString(R.string.tickets_code) + ": " + t.getHash());
fireNotification(c,t.getNotificationId(),openIntent,c.getString(R.string.application_name),text,rows,t.getCity(),ticker,smallIcon,largeIcon,actions,keepNotification);
}

public static void notifyTicket ( Context c , @ NonNull Ticket t , boolean keepNotification ) { String text ; String ticker ; int smallIcon ; int largeIcon ; int status ; switch ( TicketsAdapter . getValidityStatus ( t . getStatus ( ) , t . getValidTo ( ) ) ) { case TicketProvider . Tickets . STATUS_VALID : case TicketProvider . Tickets . STATUS_VALID_EXPIRING : text = c . getString ( R . string . notif_valid_text , FormatUtil . formatDateTimeDifference ( t . getValidTo ( ) ) ) ; ticker = c . getString ( R . string . notif_valid_ticker ) ; smallIcon = R . drawable . notification_small_ready ; largeIcon = R . drawable . notification_big_ready ; status = TicketProvider . Tickets . STATUS_VALID_EXPIRING ; break ; case TicketProvider . Tickets . STATUS_EXPIRING : case TicketProvider . Tickets . STATUS_EXPIRING_EXPIRED : text = c . getString ( R . string . notif_expiring_text , FormatUtil . formatTime ( t . getValidTo ( ) ) ) ; ticker = c . getString ( R . string . notif_expiring_ticker ) ; smallIcon = R . drawable . notification_small_warning ; largeIcon = R . drawable . notification_big_warning ; status = TicketProvider . Tickets . STATUS_EXPIRING_EXPIRED ; break ; case TicketProvider . Tickets . STATUS_EXPIRED : text = c . getString ( R . string . notif_expired_text , FormatUtil . formatTime ( t . getValidTo ( ) ) ) ; ticker = c . getString ( R . string . notif_expired_ticker ) ; smallIcon = R . drawable . notification_small_expired ; largeIcon = R . drawable . notification_big_expired ; status = TicketProvider . Tickets . STATUS_EXPIRED ; break ; default : return ; } Intent intent = new Intent ( c , WearableService . class ) ; intent . setAction ( "sent_notification_to_wear" ) ; intent . putExtra ( "ticket" , t ) ; intent . putExtra ( "status" , status ) ; c . startService ( intent ) ; Intent i = new Intent ( c , MainActivity . class ) ; i . addFlags ( Intent . FLAG_ACTIVITY_SINGLE_TOP | Intent . FLAG_ACTIVITY_CLEAR_TOP ) ; i . putExtra ( MainActivity . EXTRA_TICKET_ID , t . getId ( ) ) ; PendingIntent openIntent = PendingIntent . getActivity ( c , t . getNotificationId ( ) , i , PendingIntent . FLAG_CANCEL_CURRENT ) ; Intent i2 = new Intent ( c , MainActivity . class ) ; i2 . addFlags ( Intent . FLAG_ACTIVITY_SINGLE_TOP | Intent . FLAG_ACTIVITY_CLEAR_TOP ) ; i2 . putExtra ( MainActivity . EXTRA_TICKET_ID , t . getId ( ) ) ; i2 . putExtra ( MainActivity . EXTRA_SHOW_SMS , true ) ; PendingIntent showSmsIntent = PendingIntent . getActivity ( c , t . getNotificationId ( ) + 1000 , i2 , PendingIntent . FLAG_CANCEL_CURRENT ) ; List < Action > actions = new ArrayList < Action > ( ) ; actions . add ( new Action ( R . drawable . notification_show_sms , R . string . notif_show_sms , showSmsIntent ) ) ; List < String > rows = new ArrayList < String > ( ) ; rows . add ( text ) ; rows . add ( c . getString ( R . string . tickets_valid_from ) + ": " + FormatUtil . formatDateTime ( t . getValidFrom ( ) ) ) ; rows . add ( c . getString ( R . string . tickets_code ) + ": " + t . getHash ( ) ) ; fireNotification ( c , t . getNotificationId ( ) , openIntent , c . getString ( R . string . application_name ) , text , rows , t . getCity ( ) , ticker , smallIcon , largeIcon , actions , keepNotification ) ; }
posts notification about new sms ticket .
