1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.graphics.pdf.models.jni; 18 19 import android.annotation.Nullable; 20 import android.graphics.pdf.PdfDocumentProxy; 21 import android.graphics.pdf.utils.Preconditions; 22 23 /** 24 * A class that holds either a successfully loaded {@link PdfDocumentProxy}, or the reason why it 25 * failed. 26 * 27 * @hide 28 */ 29 public class LoadPdfResult { 30 31 public final PdfStatus status; 32 @Nullable 33 public final PdfDocumentProxy pdfDocument; 34 35 public final float pdfSizeInKb; 36 LoadPdfResult(int status, @Nullable PdfDocumentProxy pdfDocument, float pdfSizeInKb)37 public LoadPdfResult(int status, @Nullable PdfDocumentProxy pdfDocument, float pdfSizeInKb) { 38 if (status == PdfStatus.LOADED.getNumber()) { 39 Preconditions.checkArgument(pdfDocument != null, "Missing PdfDocumentProxy"); 40 } else { 41 Preconditions.checkArgument(pdfDocument == null, "Shouldn't construct " 42 + "broken PdfDocumentProxy"); 43 } 44 // TODO(b/324910716): Potentially error-prone as is dependent on Status in document.h 45 this.status = PdfStatus.values()[status]; 46 this.pdfDocument = pdfDocument; 47 this.pdfSizeInKb = pdfSizeInKb; 48 } 49 } 50