|
62 | 62 | import com.github.mobile.util.TimeUtils; |
63 | 63 | import com.viewpagerindicator.R.layout; |
64 | 64 |
|
| 65 | +import java.text.NumberFormat; |
| 66 | +import java.util.List; |
| 67 | + |
65 | 68 | import org.eclipse.egit.github.core.Comment; |
| 69 | +import org.eclipse.egit.github.core.Commit; |
66 | 70 | import org.eclipse.egit.github.core.CommitComment; |
67 | 71 | import org.eclipse.egit.github.core.Download; |
68 | 72 | import org.eclipse.egit.github.core.Issue; |
|
90 | 94 | */ |
91 | 95 | public class NewsListAdapter extends ItemListAdapter<Event, NewsItemView> { |
92 | 96 |
|
| 97 | + private static final NumberFormat NUMBER_FORMAT = NumberFormat |
| 98 | + .getIntegerInstance(); |
| 99 | + |
93 | 100 | /** |
94 | 101 | * Can the given event be rendered by this view holder? |
95 | 102 | * |
@@ -396,6 +403,47 @@ private static void formatPush(Event event, StyledText main, |
396 | 403 | main.append(" at "); |
397 | 404 |
|
398 | 405 | boldRepo(main, event); |
| 406 | + |
| 407 | + final List<Commit> commits = payload.getCommits(); |
| 408 | + int size = commits != null ? commits.size() : -1; |
| 409 | + if (size > 0) { |
| 410 | + if (size != 1) |
| 411 | + details.append(NUMBER_FORMAT.format(size)).append( |
| 412 | + " new commits"); |
| 413 | + else |
| 414 | + details.append("1 new commit"); |
| 415 | + |
| 416 | + int max = 3; |
| 417 | + int appended = 0; |
| 418 | + for (Commit commit : commits) { |
| 419 | + if (commit == null) |
| 420 | + continue; |
| 421 | + |
| 422 | + details.append('\n'); |
| 423 | + |
| 424 | + String sha = commit.getSha(); |
| 425 | + if (TextUtils.isEmpty(sha)) |
| 426 | + continue; |
| 427 | + if (sha.length() > 7) |
| 428 | + details.monospace(sha.substring(0, 7)); |
| 429 | + else |
| 430 | + details.monospace(sha); |
| 431 | + |
| 432 | + String message = commit.getMessage(); |
| 433 | + if (!TextUtils.isEmpty(message)) { |
| 434 | + details.append(' '); |
| 435 | + int newline = message.indexOf('\n'); |
| 436 | + if (newline > 0) |
| 437 | + details.append(message.subSequence(0, newline)); |
| 438 | + else |
| 439 | + details.append(message); |
| 440 | + } |
| 441 | + |
| 442 | + appended++; |
| 443 | + if (appended == max) |
| 444 | + break; |
| 445 | + } |
| 446 | + } |
399 | 447 | } |
400 | 448 |
|
401 | 449 | private static void formatTeamAdd(Event event, StyledText main, |
|
0 commit comments