mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Replace .toList() with .collect()
.toList() was only introduced to android in api level 34, which is newer than this module's min_sdk_version. Replace it with .collect(). This was found while updating android lint. Flag: EXEMPT refactor Bug: 394096385 Test: Presubmits Change-Id: Id8d1de1531b67a7daf448e45592b7ef78f685fc2
This commit is contained in:
@@ -399,8 +399,9 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
|
||||
private List<DisplayOption> filterByColumnCount(
|
||||
List<DisplayOption> allOptions, int numColumns) {
|
||||
return allOptions.stream().filter(
|
||||
option -> option.grid.numColumns == numColumns).toList();
|
||||
return allOptions.stream()
|
||||
.filter(option -> option.grid.numColumns == numColumns)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -284,6 +284,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -2250,8 +2251,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
*/
|
||||
@Override
|
||||
public void bindItems(final List<ItemInfo> items, final boolean forceAnimateIcons) {
|
||||
bindInflatedItems(items.stream().map(i -> Pair.create(
|
||||
i, getItemInflater().inflateItem(i, getModelWriter()))).toList(),
|
||||
bindInflatedItems(items.stream()
|
||||
.map(i -> Pair.create(i, getItemInflater().inflateItem(i, getModelWriter())))
|
||||
.collect(Collectors.toList()),
|
||||
forceAnimateIcons ? new AnimatorSet() : null);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Contains the logic of a reorder.
|
||||
@@ -143,12 +144,14 @@ public class ReorderAlgorithm {
|
||||
// and not by the views hash which is "random".
|
||||
// The views are sorted twice, once for the X position and a second time for the Y position
|
||||
// to ensure same order everytime.
|
||||
Comparator comparator = Comparator.comparing(
|
||||
view -> ((CellLayoutLayoutParams) ((View) view).getLayoutParams()).getCellX()
|
||||
Comparator<View> comparator = Comparator.comparing(
|
||||
(View view) -> ((CellLayoutLayoutParams) view.getLayoutParams()).getCellX()
|
||||
).thenComparing(
|
||||
view -> ((CellLayoutLayoutParams) ((View) view).getLayoutParams()).getCellY()
|
||||
(View view) -> ((CellLayoutLayoutParams) view.getLayoutParams()).getCellY()
|
||||
);
|
||||
List<View> views = solution.map.keySet().stream().sorted(comparator).toList();
|
||||
List<View> views = solution.map.keySet().stream()
|
||||
.sorted(comparator)
|
||||
.collect(Collectors.toList());
|
||||
for (View child : views) {
|
||||
if (child == ignoreView) continue;
|
||||
CellAndSpan c = solution.map.get(child);
|
||||
|
||||
@@ -390,8 +390,9 @@ public class BaseLauncherBinder {
|
||||
|
||||
ModelWriter writer = mApp.getModel()
|
||||
.getWriter(false /* verifyChanges */, CellPosMapper.DEFAULT, null);
|
||||
List<Pair<ItemInfo, View>> bindItems = items.stream().map(i ->
|
||||
Pair.create(i, inflater.inflateItem(i, writer, null))).toList();
|
||||
List<Pair<ItemInfo, View>> bindItems = items.stream()
|
||||
.map(i -> Pair.create(i, inflater.inflateItem(i, writer, null)))
|
||||
.collect(Collectors.toList());
|
||||
executeCallbacksTask(c -> c.bindInflatedItems(bindItems), executor);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,8 @@ public class GridSizeMigrationDBController {
|
||||
List<DbEntry> filteredDstHotseatItems = dstHotseatItems;
|
||||
if (srcHotseatSize < destHotseatSize) {
|
||||
filteredDstHotseatItems = filteredDstHotseatItems.stream()
|
||||
.filter(entry -> entry.screenId < srcHotseatSize).toList();
|
||||
.filter(entry -> entry.screenId < srcHotseatSize)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
final List<DbEntry> dstWorkspaceItems = destReader.loadAllWorkspaceEntries();
|
||||
final List<DbEntry> hotseatToBeAdded = new ArrayList<>(1);
|
||||
@@ -237,9 +238,12 @@ public class GridSizeMigrationDBController {
|
||||
Collections.sort(hotseatToBeAdded);
|
||||
Collections.sort(workspaceToBeAdded);
|
||||
|
||||
List<Integer> idsInUse = dstWorkspaceItems.stream().map(entry -> entry.id).collect(
|
||||
Collectors.toList());
|
||||
idsInUse.addAll(dstHotseatItems.stream().map(entry -> entry.id).toList());
|
||||
List<Integer> idsInUse = dstWorkspaceItems.stream()
|
||||
.map(entry -> entry.id)
|
||||
.collect(Collectors.toList());
|
||||
idsInUse.addAll(dstHotseatItems.stream()
|
||||
.map(entry -> entry.id)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Migrate hotseat
|
||||
solveHotseatPlacement(helper, destHotseatSize,
|
||||
@@ -269,7 +273,8 @@ public class GridSizeMigrationDBController {
|
||||
int screenId = destReader.mLastScreenId + 1;
|
||||
while (!workspaceToBeAdded.isEmpty()) {
|
||||
solveGridPlacement(helper, srcReader, destReader, screenId, trgX, trgY,
|
||||
workspaceToBeAdded, srcWorkspaceItems.stream().map(entry -> entry.id).toList());
|
||||
workspaceToBeAdded,
|
||||
srcWorkspaceItems.stream().map(entry -> entry.id).collect(Collectors.toList()));
|
||||
screenId++;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Utility class which maintains an instance of Launcher database and provides utility methods
|
||||
@@ -377,7 +378,7 @@ public class ModelDbController {
|
||||
// to run in grid migration based on if that grid already existed before migration or not.
|
||||
List<String> existingDBs = LauncherFiles.GRID_DB_FILES.stream()
|
||||
.filter(dbName -> mContext.getDatabasePath(dbName).exists())
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
|
||||
: createDatabaseHelper(true, new DeviceGridState(idp).getDbFile());
|
||||
@@ -460,7 +461,7 @@ public class ModelDbController {
|
||||
// to run in grid migration based on if that grid already existed before migration or not.
|
||||
List<String> existingDBs = LauncherFiles.GRID_DB_FILES.stream()
|
||||
.filter(dbName -> mContext.getDatabasePath(dbName).exists())
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
|
||||
: createDatabaseHelper(true /* forMigration */, targetDbName);
|
||||
try {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.android.launcher3.R
|
||||
import com.android.launcher3.icons.IconCache
|
||||
import com.android.launcher3.logger.LauncherAtom
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/** A type of app collection that launches multiple apps into split screen. */
|
||||
class AppPairInfo() : CollectionInfo() {
|
||||
@@ -54,7 +55,7 @@ class AppPairInfo() : CollectionInfo() {
|
||||
|
||||
/** Returns the app pair's member apps as an ArrayList of [ItemInfo]. */
|
||||
override fun getContents(): ArrayList<ItemInfo> =
|
||||
ArrayList(contents.stream().map { it as ItemInfo }.toList())
|
||||
ArrayList(contents.stream().map { it as ItemInfo }.collect(Collectors.toList()))
|
||||
|
||||
/** Returns the app pair's member apps as an ArrayList of [WorkspaceItemInfo]. */
|
||||
override fun getAppContents(): ArrayList<WorkspaceItemInfo> = contents
|
||||
|
||||
@@ -176,7 +176,7 @@ public class RestoreDbTask {
|
||||
// At this point idp.dbFile contains the name of the dbFile from the previous phone
|
||||
return LauncherFiles.GRID_DB_FILES.stream()
|
||||
.filter(dbName -> context.getDatabasePath(dbName).exists())
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -222,7 +222,8 @@ public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots
|
||||
if (shouldShowFullPageView(recommendations)) {
|
||||
// Show all widgets in single page with unlimited available height.
|
||||
return setRecommendations(
|
||||
recommendations.values().stream().flatMap(Collection::stream).toList(),
|
||||
recommendations.values().stream().flatMap(Collection::stream)
|
||||
.collect(Collectors.toList()),
|
||||
deviceProfile, /*availableHeight=*/ Float.MAX_VALUE, availableWidth,
|
||||
cellPadding);
|
||||
|
||||
@@ -369,7 +370,7 @@ public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots
|
||||
// Show only those widgets that were displayed when user first opened the picker.
|
||||
if (!mDisplayedWidgets.isEmpty()) {
|
||||
filteredRecommendedWidgets = recommendedWidgets.stream().filter(
|
||||
w -> mDisplayedWidgets.contains(w.componentName)).toList();
|
||||
w -> mDisplayedWidgets.contains(w.componentName)).collect(Collectors.toList());
|
||||
}
|
||||
Context context = getContext();
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
|
||||
@@ -87,6 +87,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
@@ -650,7 +651,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
mRecommendedWidgets = mActivityContext.getWidgetPickerDataProvider().get()
|
||||
.getRecommendations()
|
||||
.values().stream()
|
||||
.flatMap(Collection::stream).toList();
|
||||
.flatMap(Collection::stream).collect(Collectors.toList());
|
||||
mRecommendedWidgetsCount = mWidgetRecommendationsView.setRecommendations(
|
||||
mRecommendedWidgets,
|
||||
mDeviceProfile,
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.launcher3.widget.picker.util.WidgetPreviewContainerSize;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** A {@link TableLayout} for showing recommended widgets. */
|
||||
public final class WidgetsRecommendationTableLayout extends TableLayout {
|
||||
@@ -163,6 +164,7 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
|
||||
}
|
||||
|
||||
// Perform re-ordering once we have filtered out recommendations that fit.
|
||||
return filteredRows.stream().sorted(WIDGETS_TABLE_ROW_COUNT_COMPARATOR).toList();
|
||||
return filteredRows.stream().sorted(WIDGETS_TABLE_ROW_COUNT_COMPARATOR)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class WidgetsTableUtils {
|
||||
List<ArrayList<WidgetItem>> rows = groupWidgetItemsUsingRowPxWithoutReordering(
|
||||
sortedWidgetItems, context, dp, rowPx,
|
||||
cellPadding);
|
||||
return rows.stream().sorted(WIDGETS_TABLE_ROW_SIZE_COMPARATOR).toList();
|
||||
return rows.stream().sorted(WIDGETS_TABLE_ROW_SIZE_COMPARATOR).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user