diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-08-03 12:11:32 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2021-08-03 12:11:32 +0300 |
commit | 79a442550f86709cab9694a46ac54b548407ee25 (patch) | |
tree | 48505083e0b9c66cd8a5be998ef1d7418be4c3e3 /app/src/main/java/it/niedermann/nextcloud/deck/ui | |
parent | 805aa7143f02040699961b9325563be679e2d1d1 (diff) |
Make use of var keyword for complex class instances
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui')
7 files changed, 25 insertions, 27 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/tiles/EditCardTileService.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/tiles/EditCardTileService.java index 09abbfa7a..ad691c943 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/tiles/EditCardTileService.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/tiles/EditCardTileService.java @@ -13,14 +13,14 @@ public class EditCardTileService extends TileService { @Override public void onStartListening() { - Tile tile = getQsTile(); + final var tile = getQsTile(); tile.setState(Tile.STATE_ACTIVE); tile.updateTile(); } @Override public void onClick() { - Intent intent = new Intent(getApplicationContext(), PrepareCreateActivity.class); + final var intent = new Intent(getApplicationContext(), PrepareCreateActivity.class); // ensure it won't open twice if already running intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); // ask to unlock the screen if locked, then start new note intent diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java index 0dd431ff9..8345e63b9 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java @@ -1,7 +1,6 @@ package it.niedermann.nextcloud.deck.ui.view; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Color; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -42,22 +41,22 @@ public class ColorChooser extends LinearLayout { super(context, attrs); this.context = context; - final FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams( + final var params = new FlexboxLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ); params.setMargins(0, DimensionUtil.INSTANCE.dpToPx(context, R.dimen.spacer_1x), 0, 0); params.setFlexBasisPercent(.15f); - final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorChooser, 0, 0); - colors = Arrays.stream(getResources().getStringArray(a.getResourceId(R.styleable.ColorChooser_colors, 0))) + final var styles = context.obtainStyledAttributes(attrs, R.styleable.ColorChooser, 0, 0); + colors = Arrays.stream(getResources().getStringArray(styles.getResourceId(R.styleable.ColorChooser_colors, 0))) .mapToInt(Color::parseColor) .toArray(); - a.recycle(); + styles.recycle(); binding = WidgetColorChooserBinding.inflate(LayoutInflater.from(context), this, true); for (final int color : colors) { - final ImageView image = new ImageView(getContext()); + final var image = new ImageView(getContext()); image.setLayoutParams(params); image.setOnClickListener((imageView) -> { if (previouslySelectedImageView != null) { // null when first selection diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java index 3564662ce..b103e528a 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java @@ -1,7 +1,6 @@ package it.niedermann.nextcloud.deck.ui.view; import android.content.Context; -import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -24,19 +23,19 @@ public class EmptyContentView extends RelativeLayout { binding = WidgetEmptyContentViewBinding.inflate(LayoutInflater.from(context), this, true); - TypedArray a = context.obtainStyledAttributes(attrs, + final var styles = context.obtainStyledAttributes(attrs, R.styleable.EmptyContentView, 0, 0); - @StringRes int descriptionRes = a.getResourceId(R.styleable.EmptyContentView_description, NO_DESCRIPTION); + @StringRes int descriptionRes = styles.getResourceId(R.styleable.EmptyContentView_description, NO_DESCRIPTION); - binding.title.setText(getResources().getString(a.getResourceId(R.styleable.EmptyContentView_title, R.string.no_content))); + binding.title.setText(getResources().getString(styles.getResourceId(R.styleable.EmptyContentView_title, R.string.no_content))); if (descriptionRes == NO_DESCRIPTION) { binding.description.setVisibility(View.GONE); } else { binding.description.setText(getResources().getString(descriptionRes)); } - binding.image.setImageResource(a.getResourceId(R.styleable.EmptyContentView_image, R.drawable.ic_app_logo)); - a.recycle(); + binding.image.setImageResource(styles.getResourceId(R.styleable.EmptyContentView_image, R.drawable.ic_app_logo)); + styles.recycle(); } public void hideDescription() { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java index 0facc385c..9d15df896 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java @@ -4,7 +4,6 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; -import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -53,7 +52,7 @@ public class OverlappingAvatars extends RelativeLayout { } public void setAvatars(@NonNull Account account, @NonNull List<User> assignedUsers) { - @NonNull Context context = getContext(); + @NonNull final var context = getContext(); removeAllViews(); RelativeLayout.LayoutParams avatarLayoutParams; int avatarCount; @@ -62,7 +61,7 @@ public class OverlappingAvatars extends RelativeLayout { avatarLayoutParams.setMargins(0, 0, avatarCount * overlapPx, 0); avatarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - final ImageView avatar = new ImageView(context); + final var avatar = new ImageView(context); avatar.setLayoutParams(avatarLayoutParams); avatar.setPadding(avatarBorderSize, avatarBorderSize, avatarBorderSize, avatarBorderSize); @@ -79,7 +78,7 @@ public class OverlappingAvatars extends RelativeLayout { // Recalculate container size based on avatar count int size = overlapPx * (avatarCount - 1) + avatarSize; - ViewGroup.LayoutParams rememberParam = getLayoutParams(); + final var rememberParam = getLayoutParams(); rememberParam.width = size; setLayoutParams(rememberParam); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/SquareRelativeLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/SquareRelativeLayout.java index cdce90251..6937a370d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/SquareRelativeLayout.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/SquareRelativeLayout.java @@ -25,6 +25,7 @@ public class SquareRelativeLayout extends RelativeLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Set a square layout. + //noinspection SuspiciousNameCombination super.onMeasure(widthMeasureSpec, widthMeasureSpec); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/LabelChip.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/LabelChip.java index 83853f0b2..d69ff2898 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/LabelChip.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/LabelChip.java @@ -43,8 +43,8 @@ public class LabelChip extends Chip { try { int labelColor = label.getColor(); - ColorStateList c = ColorStateList.valueOf(labelColor); - setChipBackgroundColor(c); + final var colorStateList = ColorStateList.valueOf(labelColor); + setChipBackgroundColor(colorStateList); setTextColor(ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(labelColor)); } catch (IllegalArgumentException e) { DeckLog.logError(e); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/LabelLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/LabelLayout.java index 3db539e53..526bdbaef 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/LabelLayout.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/LabelLayout.java @@ -56,9 +56,9 @@ public abstract class LabelLayout extends FlexboxLayout { private void removeObsoleteLabels(List<Label> labels) { chipList: for (int i = 0; i < chipList.size(); i++) { - LabelChip currentChip = chipList.get(i); - final Label existingLabel = currentChip.getLabel(); - for (Label label : labels) { + final var currentChip = chipList.get(i); + final var existingLabel = currentChip.getLabel(); + for (final var label : labels) { if (existingLabel.equals(label)) { continue chipList; } @@ -75,15 +75,15 @@ public abstract class LabelLayout extends FlexboxLayout { private void addNewLabels(List<Label> labels) { int oldLabelSize = chipList.size(); labelList: - for (Label label : labels) { + for (final var label : labels) { for (int i = 0; i < oldLabelSize; i++) { - final LabelChip currentChip = chipList.get(i); - final Label existingLabel = currentChip.getLabel(); + final var currentChip = chipList.get(i); + final var existingLabel = currentChip.getLabel(); if (existingLabel.equals(label)) { continue labelList; } } - final LabelChip chip = createLabelChip(label); + final var chip = createLabelChip(label); addView(chip); chipList.add(chip); } |