Messaging: Replace explicit types

Change-Id: I2165b3dec73973a2a82d8b3c7c364b5f011e597d
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent 9538179c75
commit 0069df879a
124 changed files with 278 additions and 277 deletions
@@ -417,7 +417,7 @@ public class AsyncImageView extends ImageView implements MediaResourceLoadListen
private final HashSet<AsyncImageView> mAttachedViews;
public AsyncImageViewDelayLoader() {
mAttachedViews = new HashSet<AsyncImageView>();
mAttachedViews = new HashSet<>();
}
private void registerView(final AsyncImageView view) {
@@ -119,7 +119,7 @@ public class ClassZeroActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
if (mMessageQueue == null) {
mMessageQueue = new ArrayList<ContentValues>();
mMessageQueue = new ArrayList<>();
}
if (!queueMsgFromIntent(getIntent())) {
return;
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,7 +104,7 @@ public class LineWrapLayout extends ViewGroup {
int currLineHeight = 0;
// Do a dry-run first to get the line heights.
final ArrayList<Integer> lineHeights = new ArrayList<Integer>();
final ArrayList<Integer> lineHeights = new ArrayList<>();
for (int i = 0; i < childCount; i++) {
View currChild = getChildAt(i);
if (currChild.getVisibility() == GONE) {
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -158,13 +159,13 @@ public class MultiAttachmentLayout extends FrameLayout {
public MultiAttachmentLayout(final Context context, final AttributeSet attrs) {
super(context, attrs);
mPreviewViews = new ArrayList<ViewWrapper>();
mPreviewViews = new ArrayList<>();
}
public void bindAttachments(final Iterable<MessagePartData> attachments,
final Rect transitionRect, final int count) {
final ArrayList<ViewWrapper> previousViews = mPreviewViews;
mPreviewViews = new ArrayList<ViewWrapper>();
mPreviewViews = new ArrayList<>();
removeView(mPlusTextView);
mPlusTextView = null;
+2 -3
View File
@@ -118,8 +118,7 @@ public class SnackBar {
}
public static class Builder {
private static final List<SnackBarInteraction> NO_INTERACTIONS =
new ArrayList<SnackBarInteraction>();
private static final List<SnackBarInteraction> NO_INTERACTIONS = new ArrayList<>();
private final Context mContext;
private final SnackBarManager mSnackBarManager;
@@ -213,7 +212,7 @@ public class SnackBar {
mPlacement = builder.mPlacement;
mParentView = builder.mParentView;
if (builder.mInteractions == null) {
mInteractions = new ArrayList<SnackBarInteraction>();
mInteractions = new ArrayList<>();
} else {
mInteractions = builder.mInteractions;
}
@@ -122,7 +122,7 @@ public class SettingsActivity extends BugleActionBarActivity {
*/
private class SettingsListAdapter extends ArrayAdapter<SettingsItem> {
public SettingsListAdapter(final Context context) {
super(context, R.layout.settings_item_view, new ArrayList<SettingsItem>());
super(context, R.layout.settings_item_view, new ArrayList<>());
}
public void setSettingsItems(final List<SettingsItem> newList) {
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,12 +158,12 @@ public class AttachmentGridView extends GridView implements
}
}
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<>() {
@Override
public SavedState createFromParcel(final Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(final int size) {
return new SavedState[size];
@@ -310,7 +310,7 @@ public final class ContactRecipientAdapter extends BaseRecipientAdapter {
final RecipientMatchCallback callback) {
final int addressesSize = Math.min(
RecipientAlternatesAdapter.MAX_LOOKUPS, inAddresses.size());
final HashSet<String> addresses = new HashSet<String>();
final HashSet<String> addresses = new HashSet<>();
for (int i = 0; i < addressesSize; i++) {
final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase());
addresses.add(tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i));
@@ -259,8 +259,7 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
public ArrayList<ParticipantData> getRecipientParticipantDataForConversationCreation() {
final DrawableRecipientChip[] recips = getText()
.getSpans(0, getText().length(), DrawableRecipientChip.class);
final ArrayList<ParticipantData> contacts =
new ArrayList<ParticipantData>(recips.length);
final ArrayList<ParticipantData> contacts = new ArrayList<>(recips.length);
for (final DrawableRecipientChip recipient : recips) {
final RecipientEntry entry = recipient.getEntry();
if (entry != null && entry.isValid() && entry.getDestination() != null &&
@@ -277,7 +276,7 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
* consumer with determining quickly whether a contact is currently selected.
*/
public Set<String> getSelectedDestinations() {
Set<String> set = new HashSet<String>();
Set<String> set = new HashSet<>();
final DrawableRecipientChip[] recips = getText()
.getSpans(0, getText().length(), DrawableRecipientChip.class);
@@ -67,7 +67,7 @@ public class ContactRecipientPhotoManager implements PhotoManager {
new AvatarRequestDescriptor(avatarUri, mIconSize, mIconSize);
final BindableMediaRequest<ImageResource> req = descriptor.buildAsyncMediaRequest(
mContext,
new MediaResourceLoadListener<ImageResource>() {
new MediaResourceLoadListener<>() {
@Override
public void onMediaResourceLoaded(final MediaRequest<ImageResource> request,
final ImageResource resource, final boolean isCached) {
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,7 +112,7 @@ public class ContactSectionIndexer implements SectionIndexer {
}
this.mSections = sections;
mSectionStartingPositions = new ArrayList<Integer>(counts.length);
mSectionStartingPositions = new ArrayList<>(counts.length);
int position = 0;
for (int i = 0; i < counts.length; i++) {
if (TextUtils.isEmpty(mSections[i])) {
@@ -131,8 +132,8 @@ public class ContactSectionIndexer implements SectionIndexer {
// The result is stored into two arrays, one for the section header (i.e. the first
// character), and one for the starting position, which is guaranteed to be sorted in
// ascending order.
final ArrayList<String> sections = new ArrayList<String>();
mSectionStartingPositions = new ArrayList<Integer>();
final ArrayList<String> sections = new ArrayList<>();
mSectionStartingPositions = new ArrayList<>();
if (cursor != null) {
cursor.moveToPosition(-1);
int currentPosition = 0;
@@ -655,7 +655,7 @@ public class ComposeMessageView extends LinearLayout
mBinding.getData().hasAttachments();
final List<MessagePartData> attachments =
new ArrayList<MessagePartData>(draftMessageData.getReadOnlyAttachments());
new ArrayList<>(draftMessageData.getReadOnlyAttachments());
if (draftMessageData.getIsMms()) { // MMS case
if (draftMessageData.hasAttachments()) {
if (hasAttachmentsChanged) {
@@ -276,7 +276,7 @@ public class ConversationActivityUiState implements Parcelable, Cloneable {
}
public static final Parcelable.Creator<ConversationActivityUiState> CREATOR
= new Parcelable.Creator<ConversationActivityUiState>() {
= new Parcelable.Creator<>() {
@Override
public ConversationActivityUiState createFromParcel(final Parcel in) {
return new ConversationActivityUiState(in);
@@ -508,7 +508,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(manager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator() {
private final List<ViewHolder> mAddAnimations = new ArrayList<ViewHolder>();
private final List<ViewHolder> mAddAnimations = new ArrayList<>();
private PopupTransitionAnimation mPopupTransitionAnimation;
@Override
@@ -126,7 +126,7 @@ public class SimSelectorView extends FrameLayout implements SimSelectorItemView.
*/
private class SimSelectorAdapter extends ArrayAdapter<SubscriptionListEntry> {
public SimSelectorAdapter(final Context context) {
super(context, R.layout.sim_selector_item_view, new ArrayList<SubscriptionListEntry>());
super(context, R.layout.sim_selector_item_view, new ArrayList<>());
}
public void bindData(final List<SubscriptionListEntry> newList) {
@@ -134,7 +134,7 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAct
@Override
public void onActionBarArchive(final Iterable<SelectedConversation> conversations,
final boolean isToArchive) {
final ArrayList<String> conversationIds = new ArrayList<String>();
final ArrayList<String> conversationIds = new ArrayList<>();
for (final SelectedConversation conversation : conversations) {
final String conversationId = conversation.conversationId;
conversationIds.add(conversationId);
@@ -385,7 +385,7 @@ public class ConversationListFragment extends Fragment implements ConversationLi
@Override
public List<SnackBarInteraction> getSnackBarInteractions() {
final List<SnackBarInteraction> interactions = new ArrayList<SnackBarInteraction>(1);
final List<SnackBarInteraction> interactions = new ArrayList<>(1);
final SnackBarInteraction fabInteraction =
new SnackBarInteraction.BasicSnackBarInteraction(mStartNewConversationButton);
interactions.add(fabInteraction);
@@ -136,7 +136,7 @@ public class ShareIntentActivity extends BaseBugleActivity implements
// Handle sharing multiple contents.
final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (uris != null && !uris.isEmpty()) {
ArrayMap<Uri, String> uriMap = new ArrayMap<Uri, String>();
ArrayMap<Uri, String> uriMap = new ArrayMap<>();
StringBuffer strBuffer = new StringBuffer();
for (final Uri uri : uris) {
if (UriUtil.isFileUri(uri)) {
@@ -127,7 +127,7 @@ public class PeopleAndOptionsFragment extends Fragment
public void onOptionsItemViewClicked(final PeopleOptionsItemData item) {
switch (item.getItemId()) {
case PeopleOptionsItemData.SETTING_NOTIFICATION:
ArrayList<String> participantsNames = new ArrayList<String>();
ArrayList<String> participantsNames = new ArrayList<>();
for (ParticipantData participant : mOtherParticipants) {
participantsNames.add(participant.getDisplayName(true));
}
@@ -236,7 +236,7 @@ public class PeopleAndOptionsFragment extends Fragment
*/
private class PeopleListAdapter extends ArrayAdapter<ParticipantData> {
public PeopleListAdapter(final Context context) {
super(context, R.layout.people_list_item_view, new ArrayList<ParticipantData>());
super(context, R.layout.people_list_item_view, new ArrayList<>());
}
public void updateParticipants(final List<ParticipantData> newList) {
@@ -408,7 +408,7 @@ class CameraManager implements FocusOverlayManager.Listener {
}
mPendingOpenCameraIndex = mCameraIndex;
mOpenCameraTask = new AsyncTask<Integer, Void, Camera>() {
mOpenCameraTask = new AsyncTask<>() {
private Exception mException;
@Override
@@ -974,7 +974,7 @@ class CameraManager implements FocusOverlayManager.Listener {
screenHeight *= scaleFactor;
final float aspectRatio = screenWidth / (float) screenHeight;
final List<Camera.Size> sizes = new ArrayList<Camera.Size>(
final List<Camera.Size> sizes = new ArrayList<>(
mCamera.getParameters().getSupportedPictureSizes());
final int maxPixels = maxWidth * maxHeight;
@@ -989,7 +989,7 @@ class CameraManager implements FocusOverlayManager.Listener {
* aspect ratio and size as the picture if possible
*/
private Camera.Size chooseBestPreviewSize(final Camera.Size pictureSize) {
final List<Camera.Size> sizes = new ArrayList<Camera.Size>(
final List<Camera.Size> sizes = new ArrayList<>(
mCamera.getParameters().getSupportedPreviewSizes());
final float aspectRatio = pictureSize.width / (float) pictureSize.height;
final int capturePixels = pictureSize.width * pictureSize.height;
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +72,7 @@ public class GalleryGridView extends MediaPickerGridView implements
public GalleryGridView(final Context context, final AttributeSet attrs) {
super(context, attrs);
mSelectedImages = new ArrayMap<Uri, MessagePartData>();
mSelectedImages = new ArrayMap<>();
}
public void setHostInterface(final GalleryGridViewListener hostInterface) {
@@ -301,15 +302,16 @@ public class GalleryGridView extends MediaPickerGridView implements
}
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(final Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(final int size) {
return new SavedState[size];
}
};
new Parcelable.Creator<>() {
@Override
public SavedState createFromParcel(final Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(final int size) {
return new SavedState[size];
}
};
}
}
@@ -173,7 +173,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
public MediaPicker(final Context context) {
mBinding.bind(DataModel.get().createMediaPickerData(context));
mEnabledChoosers = new ArrayList<MediaChooser>();
mEnabledChoosers = new ArrayList<>();
mChoosers = new MediaChooser[] {
new CameraMediaChooser(this),
new GalleryMediaChooser(this),
@@ -432,7 +432,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
}
final MediaChooser[] enabledChoosers = new MediaChooser[mEnabledChoosers.size()];
mEnabledChoosers.toArray(enabledChoosers);
mPagerAdapter = new FixedViewPagerAdapter<MediaChooser>(enabledChoosers);
mPagerAdapter = new FixedViewPagerAdapter<>(enabledChoosers);
if (mViewPager != null) {
mViewPager.setAdapter(mPagerAdapter);
}
@@ -574,7 +574,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
}
void dispatchItemsSelected(final MessagePartData item, final boolean dismissMediaPicker) {
final List<MessagePartData> items = new ArrayList<MessagePartData>(1);
final List<MessagePartData> items = new ArrayList<>(1);
items.add(item);
dispatchItemsSelected(items, dismissMediaPicker);
}
@@ -306,7 +306,7 @@ public class FocusOverlayManager {
private void initializeFocusAreas(int focusWidth, int focusHeight,
int x, int y, int previewWidth, int previewHeight) {
if (mFocusArea == null) {
mFocusArea = new ArrayList<Object>();
mFocusArea = new ArrayList<>();
mFocusArea.add(new Area(new Rect(), 1));
}
@@ -318,7 +318,7 @@ public class FocusOverlayManager {
private void initializeMeteringAreas(int focusWidth, int focusHeight,
int x, int y, int previewWidth, int previewHeight) {
if (mMeteringArea == null) {
mMeteringArea = new ArrayList<Object>();
mMeteringArea = new ArrayList<>();
mMeteringArea.add(new Area(new Rect(), 1));
}
@@ -74,7 +74,7 @@ public class PieItem {
public void addItem(PieItem item) {
if (mItems == null) {
mItems = new ArrayList<PieItem>();
mItems = new ArrayList<>();
}
mItems.add(item);
}
@@ -149,7 +149,7 @@ public class PieRenderer extends OverlayRenderer
private void init(Context ctx) {
setVisible(false);
mItems = new ArrayList<PieItem>();
mItems = new ArrayList<>();
Resources res = ctx.getResources();
mRadius = (int) res.getDimensionPixelSize(R.dimen.pie_radius_start);
mCircleSize = mRadius - res.getDimensionPixelSize(R.dimen.focus_radius_offset);
@@ -53,8 +53,8 @@ public class RenderOverlay extends FrameLayout {
mRenderView = new RenderView(context);
addView(mRenderView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
mClients = new ArrayList<Renderer>(10);
mTouchClients = new ArrayList<Renderer>(10);
mClients = new ArrayList<>(10);
mTouchClients = new ArrayList<>(10);
setWillNotDraw(false);
addRenderer(new PieRenderer(context));