Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
FongMi committed Jun 11, 2023
1 parent 0487515 commit 6081fdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ public SubtitleView(Context context, @Nullable AttributeSet attrs) {

public SubtitleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
strokeWidth = Utils.dp2px(getContext(), 0.6f);
strokeWidth = Utils.dp2px(getContext(), 0.8f);
}

public void onSubtitleChanged(String text) {
if (TextUtils.isEmpty(text)) {
setText("");
} else {
setText(Html.fromHtml(text.replaceAll("\\{\\\\.*?\\}", "")));
}
setText(TextUtils.isEmpty(text) ? "" : Html.fromHtml(text.replaceAll("\\{\\\\.*?\\}", "")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class Utils {
public static final String USER_AGENT = "User-Agent";

public static float dp2px(Context context, float dpValue) {
return Math.round((dpValue * context.getResources().getDisplayMetrics().densityDpi) / DisplayMetrics.DENSITY_DEFAULT);
return (dpValue * context.getResources().getDisplayMetrics().densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
}
}

0 comments on commit 6081fdc

Please sign in to comment.