package o; import android.content.ClipData; import android.content.Context; import android.text.Editable; import android.text.Selection; import android.text.Spanned; import android.view.View; import android.widget.TextView; /* renamed from: o.YMa, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C1205YMa implements HVe { @Override // o.HVe public final irq e(View view, irq irqVar) { if (irqVar.b() == 2) { return irqVar; } ClipData qT_ = irqVar.qT_(); int d = irqVar.d(); TextView textView = (TextView) view; Editable editable = (Editable) textView.getText(); Context context = textView.getContext(); boolean z = false; for (int i = 0; i < qT_.getItemCount(); i++) { CharSequence wH_ = IeS.wH_(context, qT_.getItemAt(i), d); if (wH_ != null) { if (!z) { wG_(editable, wH_); z = true; } else { editable.insert(Selection.getSelectionEnd(editable), "\n"); editable.insert(Selection.getSelectionEnd(editable), wH_); } } } return null; } private static void wG_(Editable editable, CharSequence charSequence) { int selectionStart = Selection.getSelectionStart(editable); int selectionEnd = Selection.getSelectionEnd(editable); int max = Math.max(0, Math.min(selectionStart, selectionEnd)); int max2 = Math.max(0, Math.max(selectionStart, selectionEnd)); Selection.setSelection(editable, max2); editable.replace(max, max2, charSequence); } /* renamed from: o.YMa$IeS */ /* loaded from: classes.dex */ static final class IeS { static CharSequence wH_(Context context, ClipData.Item item, int i) { if ((i & 1) != 0) { CharSequence coerceToText = item.coerceToText(context); return coerceToText instanceof Spanned ? coerceToText.toString() : coerceToText; } return item.coerceToStyledText(context); } } }