Merge pull request #58 from TouchInstinct/phone_span_gfix

warning of PhoneSpan fixed
This commit is contained in:
Gavriil 2017-04-08 22:47:13 +03:00 committed by GitHub
commit 710bb184b9
1 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package ru.touchin.roboswag.components.utils.spans; package ru.touchin.roboswag.components.utils.spans;
import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -19,7 +20,6 @@ public class PhoneSpan extends URLSpan {
super(phoneNumber); super(phoneNumber);
} }
@SuppressWarnings("PMD.AvoidCatchingThrowable")
@Override @Override
public void onClick(@NonNull final View widget) { public void onClick(@NonNull final View widget) {
super.onClick(widget); super.onClick(widget);
@ -27,9 +27,8 @@ public class PhoneSpan extends URLSpan {
final Intent intent = new Intent(Intent.ACTION_DIAL); final Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(getURL())); intent.setData(Uri.parse(getURL()));
widget.getContext().startActivity(intent); widget.getContext().startActivity(intent);
// it should catch throwable to not crash in production if there are problems with startActivity() } catch (final ActivityNotFoundException exception) {
} catch (final Throwable throwable) { Lc.assertion(exception);
Lc.assertion(throwable);
} }
} }