|
3 | 3 | import android.content.Context;
|
4 | 4 | import android.content.Intent;
|
5 | 5 | import android.util.Log;
|
| 6 | +import android.widget.RemoteViews; |
6 | 7 | import android.widget.RemoteViewsService;
|
7 | 8 |
|
8 | 9 | import com.j256.ormlite.stmt.QueryBuilder;
|
@@ -52,6 +53,29 @@ public int getCount() {
|
52 | 53 | return messageList.size();
|
53 | 54 | }
|
54 | 55 |
|
| 56 | + @Override |
| 57 | + public RemoteViews getViewAt(int position) { |
| 58 | + RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget_row); |
| 59 | + Message message = messageList.get(position); |
| 60 | + if (message.getType() == MessageType.STREAM_MESSAGE) { |
| 61 | + remoteView.setTextViewText(R.id.widget_header, message.getStream().getName() + " > " + message.getSubject()); |
| 62 | + } else { |
| 63 | + remoteView.setTextViewText(R.id.widget_header, message.getDisplayRecipient(ZulipApp.get())); |
| 64 | + } |
| 65 | + remoteView.setTextViewText(R.id.widget_sendername, message.getSender().getName()); |
| 66 | + remoteView.setTextViewText(R.id.widget_message, message.getFormattedContent(ZulipApp.get())); |
| 67 | + |
| 68 | + if (from.equals("today")) { |
| 69 | + remoteView.setTextViewText(R.id.widget_timestamp, DateUtils.formatDateTime(context, message.getTimestamp().getTime(), DateUtils.FORMAT_SHOW_TIME)); |
| 70 | + } else { |
| 71 | + remoteView.setTextViewText(R.id.widget_timestamp, DateUtils.formatDateTime(context, message |
| 72 | + .getTimestamp().getTime(), DateUtils.FORMAT_SHOW_DATE |
| 73 | + | DateUtils.FORMAT_ABBREV_MONTH |
| 74 | + | DateUtils.FORMAT_SHOW_TIME)); |
| 75 | + } |
| 76 | + return remoteView; |
| 77 | + } |
| 78 | + |
55 | 79 | @Override
|
56 | 80 | public RemoteViews getLoadingView() {
|
57 | 81 | return null;
|
|
0 commit comments