Simplify code
This commit is contained in:
parent
aab09c0c65
commit
50b85a7734
1 changed files with 17 additions and 17 deletions
|
@ -34,30 +34,30 @@ public final class NewPipeTextViewHelper {
|
|||
* deselecting it, otherwise an exception
|
||||
*/
|
||||
public static boolean shareSelectedTextWithShareUtils(@NonNull final TextView textView) {
|
||||
if (!(textView instanceof NewPipeEditText)) {
|
||||
final CharSequence textViewText;
|
||||
if (textView instanceof NewPipeTextView) {
|
||||
final NewPipeTextView newPipeTextView = (NewPipeTextView) textView;
|
||||
final CharSequence text = newPipeTextView.getText();
|
||||
final CharSequence selectedText = getSelectedText(newPipeTextView, text);
|
||||
textViewText = newPipeTextView.getText();
|
||||
} else {
|
||||
textViewText = textView.getText();
|
||||
}
|
||||
|
||||
shareSelectedTextIfNotNullAndNotEmpty(newPipeTextView, selectedText);
|
||||
final CharSequence selectedText = getSelectedText(textView, textViewText);
|
||||
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
|
||||
|
||||
final Spannable spannable = (text instanceof Spannable) ? (Spannable) text : null;
|
||||
Selection.setSelection(spannable, newPipeTextView.getSelectionEnd());
|
||||
} else if (textView instanceof NewPipeEditText) {
|
||||
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());
|
||||
} else {
|
||||
final CharSequence text = textView.getText();
|
||||
final CharSequence selectedText = getSelectedText(textView, text);
|
||||
|
||||
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
|
||||
|
||||
final Spannable spannable = (text instanceof Spannable) ? (Spannable) text : null;
|
||||
Selection.setSelection(spannable, textView.getSelectionEnd());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue