|
| 1 | +package com.panda912.defensor.internal; |
| 2 | + |
| 3 | +import android.text.Editable; |
| 4 | + |
| 5 | +import com.panda912.defensor.CrashDefensor; |
| 6 | +import com.panda912.defensor.ErrorCode; |
| 7 | + |
| 8 | +/** |
| 9 | + * Created by panda on 2022/2/22 15:22 |
| 10 | + */ |
| 11 | +public class EditableDefensor { |
| 12 | + |
| 13 | + public static Editable replace(Editable editable, int st, int en, CharSequence source, int start, int end) { |
| 14 | + try { |
| 15 | + return editable.replace(st, en, source, start, end); |
| 16 | + } catch (IndexOutOfBoundsException e) { |
| 17 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.replace(int st, int en, CharSequence source, int start, int end) throw IndexOutOfBoundsException", e); |
| 18 | + } |
| 19 | + return editable; |
| 20 | + } |
| 21 | + |
| 22 | + public static Editable replace(Editable editable, int st, int en, CharSequence text) { |
| 23 | + try { |
| 24 | + return editable.replace(st, en, text); |
| 25 | + } catch (IndexOutOfBoundsException e) { |
| 26 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.replace(int st, int en, CharSequence text) throw IndexOutOfBoundsException", e); |
| 27 | + } |
| 28 | + return editable; |
| 29 | + } |
| 30 | + |
| 31 | + public static Editable insert(Editable editable, int where, CharSequence text, int start, int end) { |
| 32 | + try { |
| 33 | + return editable.insert(where, text, start, end); |
| 34 | + } catch (IndexOutOfBoundsException e) { |
| 35 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.insert(int where, CharSequence text, int start, int end) throw IndexOutOfBoundsException", e); |
| 36 | + } |
| 37 | + return editable; |
| 38 | + } |
| 39 | + |
| 40 | + public static Editable insert(Editable editable, int where, CharSequence text) { |
| 41 | + try { |
| 42 | + return editable.insert(where, text); |
| 43 | + } catch (IndexOutOfBoundsException e) { |
| 44 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.insert(int where, CharSequence text) throw IndexOutOfBoundsException", e); |
| 45 | + } |
| 46 | + return editable; |
| 47 | + } |
| 48 | + |
| 49 | + public static Editable delete(Editable editable, int st, int en) { |
| 50 | + try { |
| 51 | + return editable.delete(st, en); |
| 52 | + } catch (IndexOutOfBoundsException e) { |
| 53 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.delete(int st, int en) throw IndexOutOfBoundsException", e); |
| 54 | + } |
| 55 | + return editable; |
| 56 | + } |
| 57 | + |
| 58 | + public static Editable append(Editable editable, CharSequence text) { |
| 59 | + try { |
| 60 | + return editable.append(text); |
| 61 | + } catch (IndexOutOfBoundsException e) { |
| 62 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.append(CharSequence text) throw IndexOutOfBoundsException", e); |
| 63 | + } |
| 64 | + return editable; |
| 65 | + } |
| 66 | + |
| 67 | + public static Editable append(Editable editable, CharSequence text, int start, int end) { |
| 68 | + try { |
| 69 | + return editable.append(text, start, end); |
| 70 | + } catch (IndexOutOfBoundsException e) { |
| 71 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.append(CharSequence text, int start, int end) throw IndexOutOfBoundsException", e); |
| 72 | + } |
| 73 | + return editable; |
| 74 | + } |
| 75 | + |
| 76 | + public static Editable append(Editable editable, char text) { |
| 77 | + try { |
| 78 | + return editable.append(text); |
| 79 | + } catch (IndexOutOfBoundsException e) { |
| 80 | + CrashDefensor.onCrash(ErrorCode.IndexOutOfBoundsException, "Editable.append(char text) throw IndexOutOfBoundsException", e); |
| 81 | + } |
| 82 | + return editable; |
| 83 | + } |
| 84 | + |
| 85 | +} |
0 commit comments