Skip to content

Commit

Permalink
perf: Remove unneeded arguments from ImageTextAndButtonView
Browse files Browse the repository at this point in the history
  • Loading branch information
frknkrc44 committed Jul 28, 2024
1 parent 635004d commit c32c69d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ public void onAnimationStart(Animator animation) {
@Override
public void onAnimationEnd(Animator animation) {
contentView.removeAllViews();
View view = new ImageTextAndButtonView(
SetupActivityV2.this, content,
content.extraNextButton, content.smallImage);
View view = new ImageTextAndButtonView(SetupActivityV2.this, content);
view.setAlpha(0);
contentView.addView(view);
view.animate().alpha(1).setDuration(duration).start();
Expand All @@ -183,8 +181,7 @@ public void onAnimationRepeat(Animator animation) {
}).start();
} else {
contentView.removeAllViews();
contentView.addView(new ImageTextAndButtonView(
this, content, content.extraNextButton, content.smallImage));
contentView.addView(new ImageTextAndButtonView(this, content));
}

currentPage = page;
Expand Down Expand Up @@ -269,8 +266,7 @@ private class ImageTextAndButtonView extends LinearLayout {
final TextView textView;
final Button buttonView;

private ImageTextAndButtonView(Context context, PageContent content,
boolean extraNextButton, boolean smallImage) {
private ImageTextAndButtonView(Context context, PageContent content) {
super(context);
setLayoutParams(new LayoutParams(-1, -1));
imageView = new ImageView(context);
Expand All @@ -281,7 +277,7 @@ private ImageTextAndButtonView(Context context, PageContent content,
addView(textView);
addView(buttonView);
int imageSize = DensityUtils.dpInt(96);
int imageLayoutSize = smallImage ? (int) (imageSize / 2f) : imageSize;
int imageLayoutSize = content.smallImage ? (int) (imageSize / 2f) : imageSize;
imageView.setLayoutParams(new LayoutParams(imageLayoutSize, imageLayoutSize));
buttonView.setLayoutParams(new LayoutParams(imageSize * 3, -2));
setGravity(Gravity.CENTER);
Expand All @@ -306,7 +302,7 @@ private ImageTextAndButtonView(Context context, PageContent content,
buttonView.setText(content.buttonText);
buttonView.setOnClickListener(content.onButtonClick);

if (extraNextButton) {
if (content.extraNextButton) {
Button nextButton = new Button(context);
LayoutParams buttonParams = (LayoutParams) buttonView.getLayoutParams();
buttonParams = new LayoutParams(buttonParams.width, buttonParams.height);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/org/blinksd/board/views/SuperBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,9 @@ public void run() {
SuperBoardApplication.mainHandler.post(() -> sendMessage(what, v));
} catch (InterruptedException ignored) {}

threads.remove(this);
try {
threads.remove(this);
} catch (Throwable ignored) {}
}
});
threads.get(threads.size() - 1).start();
Expand Down

0 comments on commit c32c69d

Please sign in to comment.