1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Adress new requested changes

This commit is contained in:
TiA4f8R 2021-10-16 15:32:56 +02:00
parent a744775fe7
commit ddaafb68c8
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD

View File

@ -31,30 +31,10 @@ public final class NewPipeTextViewHelper {
* {@link TextView standard TextViews} are supported).
*/
public static void shareSelectedTextWithShareUtils(@NonNull final TextView textView) {
if (!(textView instanceof NewPipeEditText)) {
final CharSequence textViewText;
if (textView instanceof NewPipeTextView) {
final NewPipeTextView newPipeTextView = (NewPipeTextView) textView;
textViewText = newPipeTextView.getText();
} else {
textViewText = textView.getText();
}
final CharSequence selectedText = getSelectedText(textView, textViewText);
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
final Spannable spannable = (textViewText instanceof Spannable)
? (Spannable) textViewText : null;
if (spannable != null) {
Selection.setSelection(spannable, textView.getSelectionEnd());
}
} else {
final NewPipeEditText editText = (NewPipeEditText) textView;
final Spannable text = editText.getText();
final CharSequence selectedText = getSelectedText(textView, text);
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
Selection.setSelection(text, editText.getSelectionEnd());
final CharSequence textViewText = textView.getText();
shareSelectedTextIfNotNullAndNotEmpty(textView, getSelectedText(textView, textViewText));
if (textViewText instanceof Spannable) {
Selection.setSelection((Spannable) textViewText, textView.getSelectionEnd());
}
}