diff options
Diffstat (limited to 'packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java b/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java index 8a65a2e..02d2715 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java @@ -48,6 +48,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -91,14 +92,14 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> { mPersistenceManager.addPrinterAndWritePrinterHistory(printer); } - private void computeAndDeliverResult(ArrayMap<PrinterId, PrinterInfo> discoveredPrinters, - ArrayMap<PrinterId, PrinterInfo> favoritePrinters) { + private void computeAndDeliverResult(Map<PrinterId, PrinterInfo> discoveredPrinters, + List<PrinterInfo> favoritePrinters) { List<PrinterInfo> printers = new ArrayList<>(); // Add the updated favorite printers. final int favoritePrinterCount = favoritePrinters.size(); for (int i = 0; i < favoritePrinterCount; i++) { - PrinterInfo favoritePrinter = favoritePrinters.valueAt(i); + PrinterInfo favoritePrinter = favoritePrinters.get(i); PrinterInfo updatedPrinter = discoveredPrinters.remove( favoritePrinter.getId()); if (updatedPrinter != null) { @@ -215,21 +216,14 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> { // printer to use its current name instead of the historical one. mPersistenceManager.updatePrintersHistoricalNamesIfNeeded(printers); - ArrayMap<PrinterId, PrinterInfo> printersMap = new ArrayMap<>(); + Map<PrinterId, PrinterInfo> printersMap = new LinkedHashMap<>(); final int printerCount = printers.size(); for (int i = 0; i < printerCount; i++) { PrinterInfo printer = printers.get(i); printersMap.put(printer.getId(), printer); } - ArrayMap<PrinterId, PrinterInfo> favoritePrintersMap = new ArrayMap<>(); - final int favoritePrinterCount = favoritePrinters.size(); - for (int i = 0; i < favoritePrinterCount; i++) { - PrinterInfo favoritePrinter = favoritePrinters.get(i); - favoritePrintersMap.put(favoritePrinter.getId(), favoritePrinter); - } - - computeAndDeliverResult(printersMap, favoritePrintersMap); + computeAndDeliverResult(printersMap, favoritePrinters); } @Override @@ -544,7 +538,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> { mReadHistoryCompleted = true; // Deliver the printers. - updatePrinters(mDiscoverySession.getPrinters(), mHistoricalPrinters); + updatePrinters(mDiscoverySession.getPrinters(), mFavoritePrinters); // Loading the available printers if needed. loadInternal(); |