in Android/app/src/main/java/com/example/samplestickerapp/StickerPackLoader.java [49:72]
static ArrayList<StickerPack> fetchStickerPacks(Context context) throws IllegalStateException {
final Cursor cursor = context.getContentResolver().query(StickerContentProvider.AUTHORITY_URI, null, null, null, null);
if (cursor == null) {
throw new IllegalStateException("could not fetch from content provider, " + BuildConfig.CONTENT_PROVIDER_AUTHORITY);
}
HashSet<String> identifierSet = new HashSet<>();
final ArrayList<StickerPack> stickerPackList = fetchFromContentProvider(cursor);
for (StickerPack stickerPack : stickerPackList) {
if (identifierSet.contains(stickerPack.identifier)) {
throw new IllegalStateException("sticker pack identifiers should be unique, there are more than one pack with identifier:" + stickerPack.identifier);
} else {
identifierSet.add(stickerPack.identifier);
}
}
if (stickerPackList.isEmpty()) {
throw new IllegalStateException("There should be at least one sticker pack in the app");
}
for (StickerPack stickerPack : stickerPackList) {
final List<Sticker> stickers = getStickersForPack(context, stickerPack);
stickerPack.setStickers(stickers);
StickerPackValidator.verifyStickerPackValidity(context, stickerPack);
}
return stickerPackList;
}