Commit 47613fcb authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Chromium LUCI CQ

[Build] Rename recycler_view ids to avoid lint error

This CL renames RecyclerViews which set
RecyclerView#setHasFixedSize(true) to suppress the
InvalidSetHasFixedSize lint error.

The lint error is thrown because the lint check gets confused when
multiple RecyclerViews have the same id. I have looked and it does
not seem possible to write a 100% accurate lint check or errorprone
check.

The lint check should be enabled because it caught a real bug
https://chromium-review.googlesource.com/c/chromium/src/+/2559556

BUG=1064277

Change-Id: I38420437ca81bd5b127bd8d456b67612be3ff713
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563866
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832603}
parent 451c1510
......@@ -50,9 +50,9 @@ https://chromium.googlesource.com/chromium/src/+/master/build/android/docs/lint.
<issue id="InsecureBaseConfiguration">
<!-- See https://crbug.com/827265 and comment in the file for context. -->
<ignore regexp="chrome/android/java/res_base/xml/network_security_config.xml"/>
</issue>
<!-- Androidx InvalidSetHasFixedSize lint check is buggy. crbug.com/1151562 -->
<issue id="InvalidSetHasFixedSize" severity="ignore"/>
</issue>
<!-- InvalidSetHasFixedSize should not be disabled. If the check fails, check that
RecyclerViews which set RecyclerView#setHasFixedSize(true) have a globally unique id. -->
<issue id="InvalidVectorPath" severity="ignore"/>
<issue id="LogConditional" severity="ignore"/>
<issue id="LongLogTag" severity="ignore"/>
......
......@@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:id="@+id/language_ask_prompt_content_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......
......@@ -299,7 +299,7 @@ public class LanguageAskPrompt implements ModalDialogProperties.Controller {
View customView = LayoutInflater.from(activity).inflate(
R.layout.language_ask_prompt_content, null, false);
RecyclerView list = customView.findViewById(R.id.recycler_view);
RecyclerView list = customView.findViewById(R.id.language_ask_prompt_content_recycler_view);
LanguageItemAdapter adapter = new LanguageItemAdapter(activity, mLanguagesUpdate);
list.setAdapter(adapter);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(activity);
......
......@@ -217,7 +217,8 @@ public class BookmarkTest {
private void openBookmarkManager() throws InterruptedException {
if (mActivityTestRule.getActivity().isTablet()) {
mActivityTestRule.loadUrl(UrlConstants.BOOKMARKS_URL);
mItemsContainer = mActivityTestRule.getActivity().findViewById(R.id.recycler_view);
mItemsContainer = mActivityTestRule.getActivity().findViewById(
R.id.selectable_list_recycler_view);
mItemsContainer.setItemAnimator(null); // Disable animation to reduce flakiness.
mManager = ((BookmarkPage) mActivityTestRule.getActivity()
.getActivityTab()
......@@ -229,7 +230,7 @@ public class BookmarkTest {
InstrumentationRegistry.getInstrumentation(), BookmarkActivity.class,
new MenuUtils.MenuActivityTrigger(InstrumentationRegistry.getInstrumentation(),
mActivityTestRule.getActivity(), R.id.all_bookmarks_menu_id));
mItemsContainer = mBookmarkActivity.findViewById(R.id.recycler_view);
mItemsContainer = mBookmarkActivity.findViewById(R.id.selectable_list_recycler_view);
mItemsContainer.setItemAnimator(null); // Disable animation to reduce flakiness.
mManager = mBookmarkActivity.getManagerForTesting();
}
......
......@@ -156,7 +156,7 @@ public class HistoryActivityScrollingTest {
mTestObserver = new TestObserver();
mHistoryManager.getSelectionDelegateForTests().addObserver(mTestObserver);
mAdapter.registerAdapterDataObserver(mTestObserver);
mRecyclerView = activity.findViewById(R.id.recycler_view);
mRecyclerView = activity.findViewById(R.id.selectable_list_recycler_view);
}
@Test
......
......@@ -122,7 +122,7 @@ public class HistoryActivityTest {
mTestObserver = new TestObserver();
mHistoryManager.getSelectionDelegateForTests().addObserver(mTestObserver);
mAdapter.registerAdapterDataObserver(mTestObserver);
mRecyclerView = activity.findViewById(R.id.recycler_view);
mRecyclerView = activity.findViewById(R.id.selectable_list_recycler_view);
}
@Test
......
......@@ -27,6 +27,7 @@ import org.junit.runners.model.Statement;
import org.chromium.base.Promise;
import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.profiles.Profile;
......@@ -38,7 +39,6 @@ import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.components.browser_ui.widget.R;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.sync.ModelType;
import org.chromium.components.sync.protocol.AutofillWalletSpecifics;
......
......@@ -145,7 +145,7 @@ public class ContactsPickerDialogTest extends DummyUiActivityTestCase
}
private RecyclerView getRecyclerView() {
return (RecyclerView) mDialog.findViewById(R.id.recycler_view);
return (RecyclerView) mDialog.findViewById(R.id.selectable_list_recycler_view);
}
/**
......
......@@ -263,7 +263,7 @@ public class PhotoPickerDialogTest extends DummyUiActivityTestCase
public void onAnimationRepeat(Animation animation) {}
private RecyclerView getRecyclerView() {
return (RecyclerView) mDialog.findViewById(R.id.recycler_view);
return (RecyclerView) mDialog.findViewById(R.id.selectable_list_recycler_view);
}
private PhotoPickerDialog createDialogWithContentResolver(final ContentResolver contentResolver,
......
......@@ -28,7 +28,7 @@
android:layout_marginTop="@dimen/selectable_list_toolbar_height" >
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:id="@+id/selectable_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
......
......@@ -146,14 +146,15 @@ public class SelectableListLayout<E>
mAdapter = adapter;
if (recyclerView == null) {
mRecyclerView = findViewById(R.id.recycler_view);
mRecyclerView = findViewById(R.id.selectable_list_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} else {
mRecyclerView = recyclerView;
// Replace the inflated recycler view with the one supplied to this method.
FrameLayout contentView = findViewById(R.id.list_content);
RecyclerView existingView = contentView.findViewById(R.id.recycler_view);
RecyclerView existingView =
contentView.findViewById(R.id.selectable_list_recycler_view);
contentView.removeView(existingView);
contentView.addView(mRecyclerView, 0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment