Search in sources :

Example 31 with PageRange

use of android.print.PageRange in project android_frameworks_base by AOSPA.

the class PageAdapter method computePageIndexInDocument.

private int computePageIndexInDocument(int indexInAdapter) {
    int skippedAdapterPages = 0;
    final int selectedPagesCount = mSelectedPages.length;
    for (int i = 0; i < selectedPagesCount; i++) {
        PageRange pageRange = PageRangeUtils.asAbsoluteRange(mSelectedPages[i], mDocumentPageCount);
        skippedAdapterPages += pageRange.getSize();
        if (skippedAdapterPages > indexInAdapter) {
            final int overshoot = skippedAdapterPages - indexInAdapter - 1;
            return pageRange.getEnd() - overshoot;
        }
    }
    return INVALID_PAGE_INDEX;
}
Also used : PageRange(android.print.PageRange)

Example 32 with PageRange

use of android.print.PageRange in project android_frameworks_base by AOSPA.

the class PageAdapter method computeSelectedPages.

private PageRange[] computeSelectedPages() {
    ArrayList<PageRange> selectedPagesList = new ArrayList<>();
    int startPageIndex = INVALID_PAGE_INDEX;
    int endPageIndex = INVALID_PAGE_INDEX;
    final int pageCount = mConfirmedPagesInDocument.size();
    for (int i = 0; i < pageCount; i++) {
        final int pageIndex = mConfirmedPagesInDocument.keyAt(i);
        if (startPageIndex == INVALID_PAGE_INDEX) {
            startPageIndex = endPageIndex = pageIndex;
        }
        if (endPageIndex + 1 < pageIndex) {
            PageRange pageRange = new PageRange(startPageIndex, endPageIndex);
            selectedPagesList.add(pageRange);
            startPageIndex = pageIndex;
        }
        endPageIndex = pageIndex;
    }
    if (startPageIndex != INVALID_PAGE_INDEX && endPageIndex != INVALID_PAGE_INDEX) {
        PageRange pageRange = new PageRange(startPageIndex, endPageIndex);
        selectedPagesList.add(pageRange);
    }
    PageRange[] selectedPages = new PageRange[selectedPagesList.size()];
    selectedPagesList.toArray(selectedPages);
    return selectedPages;
}
Also used : ArrayList(java.util.ArrayList) PageRange(android.print.PageRange)

Example 33 with PageRange

use of android.print.PageRange in project android_frameworks_base by AOSPA.

the class PageAdapter method setConfirmedPages.

private void setConfirmedPages(PageRange[] pagesInDocument, int documentPageCount) {
    mConfirmedPagesInDocument.clear();
    final int rangeCount = pagesInDocument.length;
    for (int i = 0; i < rangeCount; i++) {
        PageRange pageRange = PageRangeUtils.asAbsoluteRange(pagesInDocument[i], documentPageCount);
        for (int j = pageRange.getStart(); j <= pageRange.getEnd(); j++) {
            mConfirmedPagesInDocument.put(j, null);
        }
    }
}
Also used : PageRange(android.print.PageRange)

Example 34 with PageRange

use of android.print.PageRange in project android_frameworks_base by AOSPA.

the class PageAdapter method computePageIndexInFile.

private int computePageIndexInFile(int pageIndexInDocument) {
    if (!PageRangeUtils.contains(mSelectedPages, pageIndexInDocument)) {
        return INVALID_PAGE_INDEX;
    }
    if (mWrittenPages == null) {
        return INVALID_PAGE_INDEX;
    }
    int indexInFile = INVALID_PAGE_INDEX;
    final int rangeCount = mWrittenPages.length;
    for (int i = 0; i < rangeCount; i++) {
        PageRange pageRange = mWrittenPages[i];
        if (!pageRange.contains(pageIndexInDocument)) {
            indexInFile += pageRange.getSize();
        } else {
            indexInFile += pageIndexInDocument - pageRange.getStart() + 1;
            return indexInFile;
        }
    }
    return INVALID_PAGE_INDEX;
}
Also used : PageRange(android.print.PageRange)

Example 35 with PageRange

use of android.print.PageRange in project android_frameworks_base by ResurrectionRemix.

the class PageRangeUtils method offset.

/**
     * Offsets a the start and end of page ranges with the given value.
     *
     * @param pageRanges The page ranges to offset.
     * @param offset The offset value.
     */
public static void offset(PageRange[] pageRanges, int offset) {
    if (offset == 0) {
        return;
    }
    final int pageRangeCount = pageRanges.length;
    for (int i = 0; i < pageRangeCount; i++) {
        final int start = pageRanges[i].getStart() + offset;
        final int end = pageRanges[i].getEnd() + offset;
        pageRanges[i] = new PageRange(start, end);
    }
}
Also used : PageRange(android.print.PageRange)

Aggregations

PageRange (android.print.PageRange)60 ArrayList (java.util.ArrayList)20 PrintAttributes (android.print.PrintAttributes)5 MediaSize (android.print.PrintAttributes.MediaSize)5 Resolution (android.print.PrintAttributes.Resolution)5 PrintDocumentInfo (android.print.PrintDocumentInfo)5 PrintJobInfo (android.print.PrintJobInfo)5 PrinterCapabilitiesInfo (android.print.PrinterCapabilitiesInfo)5 Pair (android.util.Pair)5 RemotePrintDocumentInfo (com.android.printspooler.model.RemotePrintDocument.RemotePrintDocumentInfo)5