Skip to content

Commit 0d36631

Browse files
committed
Make lambda parameter last
Change-Id: Ie4627aab27ebaf0f8e03100635e980c0a08e7d01
1 parent 65a1a37 commit 0d36631

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

auth/src/main/java/com/firebase/ui/auth/data/client/CountryListLoadTask.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public interface Listener {
5050
Set<String> whitelistedCountryIsos;
5151
Set<String> blacklistedCountryIsos;
5252

53-
public CountryListLoadTask(Listener listener,
54-
@Nullable List<String> whitelistedCountries,
55-
@Nullable List<String> blacklistedCountries) {
53+
public CountryListLoadTask(@Nullable List<String> whitelistedCountries,
54+
@Nullable List<String> blacklistedCountries,
55+
Listener listener) {
5656
mListener = listener;
5757

5858
if (whitelistedCountries != null) {

auth/src/main/java/com/firebase/ui/auth/ui/phone/CountryListSpinner.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ public void onClick(View view) {
148148
}
149149

150150
private void loadCountryList() {
151-
new CountryListLoadTask(this,
152-
whitelistedCountries,
153-
blacklistedCountries).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
151+
new CountryListLoadTask(whitelistedCountries, blacklistedCountries, this
152+
).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
154153
}
155154

156155
private void executeUserClickListener(View view) {

auth/src/test/java/com/firebase/ui/auth/ui/phone/CountryListLoadTaskTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void setUp() {
301301

302302
@Test
303303
public void testExecute_withoutUserInput_expectAllCountriesAdded() {
304-
mTask = new CountryListLoadTask(mListener, null, null);
304+
mTask = new CountryListLoadTask(null, null, mListener);
305305

306306
mTask.execute();
307307

@@ -325,7 +325,7 @@ public void testExecute_withUserWhitelistInput_expectUserCountriesAddedOnly() {
325325
List<CountryInfo> expectedOutput = new ArrayList<>();
326326
expectedOutput.add(new CountryInfo(new Locale("", "US"), 1));
327327

328-
mTask = new CountryListLoadTask(mListener, whitelistedCountryIsos, null);
328+
mTask = new CountryListLoadTask(whitelistedCountryIsos, null, mListener);
329329

330330
mTask.execute();
331331

@@ -348,7 +348,7 @@ public void testExecute_withUserBlacklistInput_expectUserCountriesRemoved() {
348348
List<CountryInfo> expectedOutput = new ArrayList<>(COUNTRY_LIST);
349349
expectedOutput.remove(new CountryInfo(new Locale("", "US"), 1));
350350

351-
mTask = new CountryListLoadTask(mListener, null, blacklistedCountryIsos);
351+
mTask = new CountryListLoadTask(null, blacklistedCountryIsos, mListener);
352352

353353
mTask.execute();
354354

@@ -373,7 +373,7 @@ public void testExecute_withCodeWhitelistInput_expectUserCodeCountriesAddedOnly(
373373
expectedOutput.add(new CountryInfo(new Locale("", iso), 1));
374374
}
375375

376-
mTask = new CountryListLoadTask(mListener, whitelistedCountries, null);
376+
mTask = new CountryListLoadTask(whitelistedCountries, null, mListener);
377377

378378
mTask.execute();
379379

@@ -401,7 +401,7 @@ public void testExecute_withCodeBlacklistInput_expectUserCodeCountriesRemoved()
401401
List<CountryInfo> expectedOutput = new ArrayList<>(COUNTRY_LIST);
402402
expectedOutput.removeAll(excludedCountries);
403403

404-
mTask = new CountryListLoadTask(mListener, null, blacklistedCountries);
404+
mTask = new CountryListLoadTask(null, blacklistedCountries, mListener);
405405

406406
mTask.execute();
407407

@@ -429,7 +429,7 @@ public void testOnPostExecute_nullListener() {
429429

430430
@Test
431431
public void testOnPostExecute() {
432-
mTask = new CountryListLoadTask(mListener, null, null);
432+
mTask = new CountryListLoadTask(null, null, mListener);
433433
mTask.onPostExecute(COUNTRY_LIST);
434434
verify(mListener).onLoadComplete(COUNTRY_LIST);
435435
}

library/quality/lint-baseline.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,4 @@
88
<location file="src/main/AndroidManifest.xml" />
99
</issue>
1010

11-
<issue
12-
id="LambdaLast"
13-
severity="Error"
14-
message="Functional interface parameters (such as parameter 1, &quot;listener&quot;, in com.firebase.ui.auth.data.client.CountryListLoadTask.CountryListLoadTask) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions"
15-
category="Interoperability:Kotlin Interoperability"
16-
priority="6"
17-
summary="Lambda Parameters Last"
18-
explanation="To improve calling this code from Kotlin,&#xA;parameter types eligible for SAM conversion should be last."
19-
url="https://android.github.io/kotlin-guides/interop.html#lambda-parameters-last"
20-
urls="https://android.github.io/kotlin-guides/interop.html#lambda-parameters-last"
21-
errorLine1=" @Nullable List&lt;String> blacklistedCountries) {"
22-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
23-
<location
24-
file="/usr/local/google/home/samstern/Projects/firebase/firebaseui-android/auth/src/main/java/com/firebase/ui/auth/data/client/CountryListLoadTask.java"
25-
line="55"
26-
column="32"/>
27-
</issue>
28-
2911
</issues>

0 commit comments

Comments
 (0)