@@ -302,8 +302,9 @@ public void bind(int position) {
302
302
303
303
removeButton .setOnClickListener (v -> removeDescription (uploadMediaDetail , position ));
304
304
captionListener = new AbstractTextWatcher (
305
- captionText -> uploadMediaDetail .setCaptionText (convertIdeographicSpaceToLatinSpace (
306
- removeLeadingAndTrailingWhitespace (captionText ))));
305
+ captionText -> uploadMediaDetail .setCaptionText (
306
+ convertIdeographicSpaceToLatinSpace (captionText .strip ()))
307
+ );
307
308
descriptionListener = new AbstractTextWatcher (
308
309
descriptionText -> uploadMediaDetail .setDescriptionText (descriptionText ));
309
310
captionItemEditText .addTextChangedListener (captionListener );
@@ -547,39 +548,6 @@ private void setUpRecentLanguagesSection(final List<Language> recentLanguages) {
547
548
}
548
549
}
549
550
550
- /**
551
- * Removes any leading and trailing whitespace from the source text.
552
- *
553
- * @param source input string
554
- * @return a string without leading and trailing whitespace
555
- */
556
- public String removeLeadingAndTrailingWhitespace (String source ) {
557
- // This method can be replaced with the inbuilt String::strip when updated to JDK 11.
558
- // Note that String::trim does not adequately remove all whitespace chars.
559
- int firstNonWhitespaceIndex = 0 ;
560
- while (firstNonWhitespaceIndex < source .length ()) {
561
- if (Character .isWhitespace (source .charAt (firstNonWhitespaceIndex ))) {
562
- firstNonWhitespaceIndex ++;
563
- } else {
564
- break ;
565
- }
566
- }
567
- if (firstNonWhitespaceIndex == source .length ()) {
568
- return "" ;
569
- }
570
-
571
- int lastNonWhitespaceIndex = source .length () - 1 ;
572
- while (lastNonWhitespaceIndex > firstNonWhitespaceIndex ) {
573
- if (Character .isWhitespace (source .charAt (lastNonWhitespaceIndex ))) {
574
- lastNonWhitespaceIndex --;
575
- } else {
576
- break ;
577
- }
578
- }
579
-
580
- return source .substring (firstNonWhitespaceIndex , lastNonWhitespaceIndex + 1 );
581
- }
582
-
583
551
/**
584
552
* Convert Ideographic space to Latin space
585
553
*
0 commit comments