Skip to content

Commit

Permalink
Add catch on FixedTextView to catch common errors (still)
Browse files Browse the repository at this point in the history
  • Loading branch information
yukuku committed Apr 24, 2019
1 parent c3e2a82 commit b9c25ac
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import yuku.alkitab.base.util.AppLog;

/**
* From https://stackoverflow.com/questions/33821008/illegalargumentexception-while-selecting-text-in-android-textview
*/
public class FixedTextView extends AppCompatTextView {
static final String TAG = FixedTextView.class.getSimpleName();

public FixedTextView(final Context context) {
super(context);
}
Expand All @@ -26,7 +29,12 @@ public FixedTextView(final Context context, final AttributeSet attrs, final int
public boolean dispatchTouchEvent(MotionEvent event) {
if (Build.VERSION.SDK_INT >= 24) {
// passthrough
return super.dispatchTouchEvent(event);
// but can still actually throws error.
try {
return super.dispatchTouchEvent(event);
} catch (Exception e) {
AppLog.e(TAG, "Still error in dispatchTouchEvent", e);
}
}

// simple workaround to https://code.google.com/p/android/issues/detail?id=191430
Expand Down

0 comments on commit b9c25ac

Please sign in to comment.