Fix various lint warnings (#4409)
- Remove empty file `ExampleInstrumentedTest.java`. - Replace deprecated `MigrationTestHelper` constructor call. - Add reified inline extension methods for `Bundle` and `Intent` to retrieve `Parcelable` and `Serializable` objects by calling the core `BundleCompat` and `IntentCompat` methods, to allow shorter syntax and removing the need to pass the class explicitly. - Replace deprecated `drawable.setColorFilter()` with simpler `drawable.setTint()` (uses blend mode `SRC_IN` by default, has the same effect as `SRC_ATOP` when the source is a color). - Rename shadowed variables (mostly caught exceptions). - Remove unnecessary `.orEmpty()` on non-null fields. - Replace `.size() == 0` with `.isEmpty()`. - Prevent `NullPointerException` when `account.getDisplayName()` is `null` in `StatusBaseViewHolder.setDisplayName()`. - Declare `customEmojis` argument as non-null in `StatusBaseViewHolder.setDisplayName()` because it calls `CustomEmojiHelper.emojify()` which now requires it to be non-null. - Prevent `NullPointerException` when no matching filter is found in `StatusBaseViewHolder.setupFilterPlaceholder()`. - Remove deprecated call to `setTargetFragment()` (target fragment is not used anyway). - Remove deprecated call to `isUserVisibleHint()` and test if the view has been destroyed instead. - Remove some unused imports. - Remove unnecessary casts. - Rename arguments to supertype names when a warning is shown. - Prevent a potential memory leak by clearing the `toolbarVisibilityDisposable` reference in `onDestroyView()`.
This commit is contained in:
parent
7dc71a5888
commit
05c7e7b806
27 changed files with 108 additions and 106 deletions
|
|
@ -200,7 +200,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
TouchDelegateHelper.expandTouchSizeToFillRow((ViewGroup) itemView, CollectionsKt.listOfNotNull(replyButton, reblogButton, favouriteButton, bookmarkButton, moreButton));
|
||||
}
|
||||
|
||||
protected void setDisplayName(@NonNull String name, @Nullable List<Emoji> customEmojis, @NonNull StatusDisplayOptions statusDisplayOptions) {
|
||||
protected void setDisplayName(@NonNull String name, @NonNull List<Emoji> customEmojis, @NonNull StatusDisplayOptions statusDisplayOptions) {
|
||||
CharSequence emojifiedName = CustomEmojiHelper.emojify(
|
||||
name, customEmojis, displayName, statusDisplayOptions.animateEmojis()
|
||||
);
|
||||
|
|
@ -790,7 +790,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
if (statusDisplayOptions.mediaPreviewEnabled() && hasPreviewableAttachment(attachments)) {
|
||||
setMediaPreviews(attachments, sensitive, listener, status.isShowingContent(), statusDisplayOptions.useBlurhash());
|
||||
|
||||
if (attachments.size() == 0) {
|
||||
if (attachments.isEmpty()) {
|
||||
hideSensitiveMediaWarning();
|
||||
}
|
||||
// Hide the unused label.
|
||||
|
|
@ -877,7 +877,14 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
}
|
||||
|
||||
filteredPlaceholderLabel.setText(itemView.getContext().getString(R.string.status_filter_placeholder_label_format, matchedFilter.getTitle()));
|
||||
final String matchedFilterTitle;
|
||||
if (matchedFilter == null) {
|
||||
matchedFilterTitle = "";
|
||||
} else {
|
||||
matchedFilterTitle = matchedFilter.getTitle();
|
||||
}
|
||||
|
||||
filteredPlaceholderLabel.setText(itemView.getContext().getString(R.string.status_filter_placeholder_label_format, matchedFilterTitle));
|
||||
filteredPlaceholderShowButton.setOnClickListener(view -> listener.clearWarningAction(getBindingAdapterPosition()));
|
||||
}
|
||||
|
||||
|
|
@ -1154,7 +1161,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
final Card card = actionable.getCard();
|
||||
|
||||
if (cardViewMode != CardViewMode.NONE &&
|
||||
actionable.getAttachments().size() == 0 &&
|
||||
actionable.getAttachments().isEmpty() &&
|
||||
actionable.getPoll() == null &&
|
||||
card != null &&
|
||||
!TextUtils.isEmpty(card.getUrl()) &&
|
||||
|
|
|
|||
|
|
@ -9,13 +9,11 @@ import android.text.method.LinkMovementMethod;
|
|||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.widget.ViewUtils;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.keylesspalace.tusky.R;
|
||||
|
|
@ -25,7 +23,6 @@ import com.keylesspalace.tusky.util.CardViewMode;
|
|||
import com.keylesspalace.tusky.util.LinkHelper;
|
||||
import com.keylesspalace.tusky.util.NoUnderlineURLSpan;
|
||||
import com.keylesspalace.tusky.util.StatusDisplayOptions;
|
||||
import com.keylesspalace.tusky.util.ViewExtensionsKt;
|
||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue