- // Create a `ByteArrayOutputStream`.
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
- // Remove the incorrect lint error that `compress()` might be null;
- assert iconBitmap != null;
-
- // Convert the favorite icon `Bitmap` to a `ByteArrayOutputStream`. `100` is the compression quality, which is ignored by `PNG`.
- iconBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
-
- // Convert the favorite icon `ByteArrayOutputStream` to a `byte[]`.
- byte[] byteArray = byteArrayOutputStream.toByteArray();
-
- // Encode the favorite icon `byte[]` as a Base64 `String`.
- String iconBase64String = Base64.encodeToString(byteArray, Base64.DEFAULT);
-
- // Store the favorite icon Base64 `String` in `iconBase64StringArrayList`.
- iconBase64StringArrayList.add(iconBase64String);
- }
-
- // Store the variables in the `Bundle`.
- argumentsBundle.putInt("Current_Page", currentPageIndex);
- argumentsBundle.putStringArrayList("URL_History", urlArrayList);
- argumentsBundle.putStringArrayList("Favorite_Icons", iconBase64StringArrayList);
-
- // Add the arguments bundle to this instance of `UrlHistoryDialog`.
- UrlHistoryDialog thisUrlHistoryDialog = new UrlHistoryDialog();
- thisUrlHistoryDialog.setArguments(argumentsBundle);
- return thisUrlHistoryDialog;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Remove the incorrect lint error that `getArguments()` might be null.
- assert getArguments() != null;
-
- // Get the `ArrayLists` from the `Arguments`.
- ArrayList<String> urlStringArrayList = getArguments().getStringArrayList("URL_History");
- ArrayList<String> favoriteIconBase64StringArrayList = getArguments().getStringArrayList("Favorite_Icons");