当前位置: 首页>>代码示例>>Java>>正文


Java PageRange类代码示例

本文整理汇总了Java中android.print.PageRange的典型用法代码示例。如果您正苦于以下问题:Java PageRange类的具体用法?Java PageRange怎么用?Java PageRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PageRange类属于android.print包,在下文中一共展示了PageRange类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: normalizeRanges

import android.print.PageRange; //导入依赖的package包/类
/**
 * Gets an array of page ranges and returns an array of integers with all ranges expanded.
 */
private static int[] normalizeRanges(final PageRange[] ranges) {
    // Expand ranges into a list of individual numbers.
    ArrayList<Integer> pages = new ArrayList<Integer>();
    for (PageRange range : ranges) {
        for (int i = range.getStart(); i <= range.getEnd(); i++) {
            pages.add(i);
        }
    }

    // Convert the list into array.
    int[] ret = new int[pages.size()];
    Iterator<Integer> iterator = pages.iterator();
    for (int i = 0; i < ret.length; i++) {
        ret[i] = iterator.next().intValue();
    }
    return ret;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:21,代码来源:PrintingControllerImpl.java

示例2: pdfWritingDone

import android.print.PageRange; //导入依赖的package包/类
@Override
public void pdfWritingDone(boolean success) {
    if (mPrintingState == PRINTING_STATE_FINISHED) return;
    mPrintingState = PRINTING_STATE_READY;
    if (success) {
        PageRange[] pageRanges = convertIntegerArrayToPageRanges(mPages);
        mOnWriteCallback.onWriteFinished(pageRanges);
    } else {
        mOnWriteCallback.onWriteFailed(mErrorMessage);
        resetCallbacks();
    }
    closeFileDescriptor(mFileDescriptor);
    mFileDescriptor = -1;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:PrintingControllerImpl.java

示例3: convertIntegerArrayToPageRanges

import android.print.PageRange; //导入依赖的package包/类
private static PageRange[] convertIntegerArrayToPageRanges(int[] pagesArray) {
    PageRange[] pageRanges;
    if (pagesArray != null) {
        pageRanges = new PageRange[pagesArray.length];
        for (int i = 0; i < pageRanges.length; i++) {
            int page = pagesArray[i];
            pageRanges[i] = new PageRange(page, page);
        }
    } else {
        // null corresponds to all pages in Chromium printing logic.
        pageRanges = new PageRange[] { PageRange.ALL_PAGES };
    }
    return pageRanges;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:PrintingControllerImpl.java

示例4: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(
        final PageRange[] ranges,
        final ParcelFileDescriptor destination,
        final CancellationSignal cancellationSignal,
        final WriteResultCallback callback) {
    mPdfGenerator.onWrite(ranges, destination, cancellationSignal,
            new WriteResultCallbackWrapperImpl(callback));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:PrintDocumentAdapterWrapper.java

示例5: pageRangesContainPage

import android.print.PageRange; //导入依赖的package包/类
private boolean pageRangesContainPage(int pageNumber, PageRange[] ranges)
{
    for(PageRange range : ranges) {
        if(pageNumber >= range.getStart() && pageNumber <= range.getEnd()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:shinobicontrols,项目名称:bitesize-kitkat,代码行数:10,代码来源:PrintShopPrintDocumentAdapter.java

示例6: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
        CancellationSignal cancellationSignal, final WriteResultCallback callback) {
    mPdfExporter.exportToPdf(destination, mAttributes, new ValueCallback<Boolean>() {
        @Override
        public void onReceiveValue(Boolean value) {
            if (value) {
                callback.onWriteFinished(new PageRange[] { PageRange.ALL_PAGES });
            } else {
                // TODO(sgurun) provide a localized error message
                callback.onWriteFailed(null);
            }
        }
    }, cancellationSignal);
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:16,代码来源:AwPrintDocumentAdapter.java

示例7: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(
        final PageRange[] ranges,
        final ParcelFileDescriptor destination,
        final CancellationSignal cancellationSignal,
        final PrintDocumentAdapterWrapper.WriteResultCallbackWrapper callback) {
    if (mPrintingContext == null) {
        callback.onWriteFailed(mErrorMessage);
        resetCallbacks();
        return;
    }

    // TODO(cimamoglu): Make use of CancellationSignal.
    mOnWriteCallback = callback;

    mFileDescriptor = destination.getFd();
    // Update file descriptor to PrintingContext mapping in the owner class.
    mPrintingContext.updatePrintingContextMap(mFileDescriptor, false);

    // We need to convert ranges list into an array of individual numbers for
    // easier JNI passing and compatibility with the native side.
    if (ranges.length == 1 && ranges[0].equals(PageRange.ALL_PAGES)) {
        // null corresponds to all pages in Chromium printing logic.
        mPages = null;
    } else {
        mPages = normalizeRanges(ranges);
    }

    if (mPrintingState == PRINTING_STATE_READY) {
        // If this onWrite is without a preceding onLayout, start Chromium PDF generation here.
        if (mPrintable.print()) {
            mPrintingState = PRINTING_STATE_STARTED_FROM_ONWRITE;
        } else {
            callback.onWriteFailed(mErrorMessage);
            resetCallbacks();
        }
    } else if (mPrintingState == PRINTING_STATE_STARTED_FROM_ONLAYOUT) {
        // Otherwise, continue previously started operation.
        mPrintingContext.askUserForSettingsReply(true);
    }
    // We are guaranteed by the framework that we will not have two onWrite calls at once.
    // We may get a CancellationSignal, after replying it (via WriteResultCallback) we might
    // get another onWrite call.
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:45,代码来源:PrintingControllerImpl.java

示例8: onWriteFinished

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWriteFinished(PageRange[] pages) {
    mCallback.onWriteFinished(pages);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:5,代码来源:PrintDocumentAdapterWrapper.java

示例9: onWrite

import android.print.PageRange; //导入依赖的package包/类
public void onWrite(PageRange apagerange[], ParcelFileDescriptor parcelfiledescriptor, CancellationSignal cancellationsignal, android.print..WriteResultCallback writeresultcallback)
    {
        cancellationsignal = new PrintedPdfDocument(mContext, mAttributes);
        apagerange = PrintHelperKitkat.access$000(PrintHelperKitkat.this, mBitmap, mAttributes.getColorMode());
        android.graphics.pdf.t t = cancellationsignal.startPage(1);
        Object obj = new RectF(t.Info().getContentRect());
        obj = PrintHelperKitkat.access$100(PrintHelperKitkat.this, mBitmap.getWidth(), mBitmap.getHeight(), ((RectF) (obj)), val$fittingMode);
        t.Canvas().drawBitmap(apagerange, ((android.graphics.Matrix) (obj)), null);
        cancellationsignal.finishPage(t);
        cancellationsignal.writeTo(new FileOutputStream(parcelfiledescriptor.getFileDescriptor()));
        writeresultcallback.onWriteFinished(new PageRange[] {
            PageRange.ALL_PAGES
        });
_L1:
        if (cancellationsignal != null)
        {
            cancellationsignal.close();
        }
        IOException ioexception;
        if (parcelfiledescriptor != null)
        {
            try
            {
                parcelfiledescriptor.close();
            }
            // Misplaced declaration of an exception variable
            catch (ParcelFileDescriptor parcelfiledescriptor) { }
        }
        if (apagerange != mBitmap)
        {
            apagerange.recycle();
        }
        return;
        ioexception;
        Log.e("PrintHelperKitkat", "Error writing printed content", ioexception);
        writeresultcallback.onWriteFailed(null);
          goto _L1
        writeresultcallback;
        if (cancellationsignal != null)
        {
            cancellationsignal.close();
        }
        if (parcelfiledescriptor != null)
        {
            try
            {
                parcelfiledescriptor.close();
            }
            // Misplaced declaration of an exception variable
            catch (ParcelFileDescriptor parcelfiledescriptor) { }
        }
        if (apagerange != mBitmap)
        {
            apagerange.recycle();
        }
        throw writeresultcallback;
    }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:58,代码来源:PrintHelperKitkat$2.java

示例10: onWrite

import android.print.PageRange; //导入依赖的package包/类
public void onWrite(PageRange apagerange[], ParcelFileDescriptor parcelfiledescriptor, CancellationSignal cancellationsignal, android.print.PrintDocumentAdapter.WriteResultCallback writeresultcallback)
        {
            cancellationsignal = new PrintedPdfDocument(mContext, mAttributes);
            apagerange = PrintHelperKitkat.access$000(PrintHelperKitkat.this, mBitmap, mAttributes.getColorMode());
            android.graphics.pdf.PdfDocument.Page page = cancellationsignal.startPage(1);
            Object obj = new RectF(page.getInfo().getContentRect());
            obj = PrintHelperKitkat.access$100(PrintHelperKitkat.this, mBitmap.getWidth(), mBitmap.getHeight(), ((RectF) (obj)), fittingMode);
            page.getCanvas().drawBitmap(apagerange, ((android.graphics.Matrix) (obj)), null);
            cancellationsignal.finishPage(page);
            cancellationsignal.writeTo(new FileOutputStream(parcelfiledescriptor.getFileDescriptor()));
            writeresultcallback.onWriteFinished(new PageRange[] {
                PageRange.ALL_PAGES
            });
_L1:
            if (cancellationsignal != null)
            {
                cancellationsignal.close();
            }
            IOException ioexception;
            if (parcelfiledescriptor != null)
            {
                try
                {
                    parcelfiledescriptor.close();
                }
                // Misplaced declaration of an exception variable
                catch (ParcelFileDescriptor parcelfiledescriptor) { }
            }
            if (apagerange != mBitmap)
            {
                apagerange.recycle();
            }
            return;
            ioexception;
            Log.e("PrintHelperKitkat", "Error writing printed content", ioexception);
            writeresultcallback.onWriteFailed(null);
              goto _L1
            writeresultcallback;
            if (cancellationsignal != null)
            {
                cancellationsignal.close();
            }
            if (parcelfiledescriptor != null)
            {
                try
                {
                    parcelfiledescriptor.close();
                }
                // Misplaced declaration of an exception variable
                catch (ParcelFileDescriptor parcelfiledescriptor) { }
            }
            if (apagerange != mBitmap)
            {
                apagerange.recycle();
            }
            throw writeresultcallback;
        }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:58,代码来源:PrintHelperKitkat$2$1.java

示例11: onWrite

import android.print.PageRange; //导入依赖的package包/类
public void onWrite(PageRange apagerange[], ParcelFileDescriptor parcelfiledescriptor, CancellationSignal cancellationsignal, android.print..WriteResultCallback writeresultcallback)
    {
        cancellationsignal = new PrintedPdfDocument(mContext, mAttributes);
        apagerange = PrintHelperKitkat.access$000(PrintHelperKitkat.this, val$bitmap, mAttributes.getColorMode());
        android.graphics.pdf.t t = cancellationsignal.startPage(1);
        Object obj = new RectF(t.Info().getContentRect());
        obj = PrintHelperKitkat.access$100(PrintHelperKitkat.this, apagerange.getWidth(), apagerange.getHeight(), ((RectF) (obj)), val$fittingMode);
        t.Canvas().drawBitmap(apagerange, ((android.graphics.Matrix) (obj)), null);
        cancellationsignal.finishPage(t);
        cancellationsignal.writeTo(new FileOutputStream(parcelfiledescriptor.getFileDescriptor()));
        writeresultcallback.onWriteFinished(new PageRange[] {
            PageRange.ALL_PAGES
        });
_L1:
        if (cancellationsignal != null)
        {
            cancellationsignal.close();
        }
        IOException ioexception;
        if (parcelfiledescriptor != null)
        {
            try
            {
                parcelfiledescriptor.close();
            }
            // Misplaced declaration of an exception variable
            catch (ParcelFileDescriptor parcelfiledescriptor) { }
        }
        if (apagerange != val$bitmap)
        {
            apagerange.recycle();
        }
        return;
        ioexception;
        Log.e("PrintHelperKitkat", "Error writing printed content", ioexception);
        writeresultcallback.onWriteFailed(null);
          goto _L1
        writeresultcallback;
        if (cancellationsignal != null)
        {
            cancellationsignal.close();
        }
        if (parcelfiledescriptor != null)
        {
            try
            {
                parcelfiledescriptor.close();
            }
            // Misplaced declaration of an exception variable
            catch (ParcelFileDescriptor parcelfiledescriptor) { }
        }
        if (apagerange != val$bitmap)
        {
            apagerange.recycle();
        }
        throw writeresultcallback;
    }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:58,代码来源:PrintHelperKitkat$1.java

示例12: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, final WriteResultCallback callback) {

    // Register a cancellation listener
    cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {
        @Override
        public void onCancel() {
            // If cancelled then ensure that the PDF doc gets thrown away
            pdfDocument.close();
            pdfDocument = null;
            // And callback
            callback.onWriteCancelled();
        }
    });

    // Iterate through the pages
    for (int currentPageNumber = 0; currentPageNumber < pageCount; currentPageNumber++) {
        // Has this page been requested?
        if(!pageRangesContainPage(currentPageNumber, pages)) {
            // Skip this page
            continue;
        }

        // Start the current page
        PdfDocument.Page page = pdfDocument.startPage(currentPageNumber);

        // Get the canvas for this page
        Canvas canvas = page.getCanvas();

        // Draw on the page
        drawPage(currentPageNumber, canvas);

        // Finish the page
        pdfDocument.finishPage(page);
    }

    // Attempt to send the completed doc out
    try {
        pdfDocument.writeTo(new FileOutputStream(destination.getFileDescriptor()));
    } catch (IOException e) {
        callback.onWriteFailed(e.toString());
        return;
    } finally {
        pdfDocument.close();
        pdfDocument = null;
    }

    // The print is complete
    callback.onWriteFinished(pages);
}
 
开发者ID:shinobicontrols,项目名称:bitesize-kitkat,代码行数:51,代码来源:PrintShopPrintDocumentAdapter.java

示例13: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
                    CancellationSignal cancellationSignal,
                    WriteResultCallback callback) {
    delegate.onWrite(pages, destination, cancellationSignal, callback);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:7,代码来源:TemplatePrinterActivity.java

示例14: onWrite

import android.print.PageRange; //导入依赖的package包/类
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
		CancellationSignal cancellationSignal, WriteResultCallback callback) {
	// TODO Auto-generated method stub
	
	 // Iterate over each page of the document,
    // check if it's in the output range.
    for (int i = 0; i < 2; i++) {
        // Check to see if this page is in the output range.
            // If so, add it to writtenPagesArray. writtenPagesArray.size()
            // is used to compute the next output page index.
            PdfDocument.Page page = document.startPage(i);

            // check for cancellation
            if (cancellationSignal.isCanceled()) {
                callback.onWriteCancelled();
                document.close();
                document = null;
                return;
            }

            // Draw page content for printing
            drawPage(page,i);

            // Rendering is complete, so page can be finalized.
            document.finishPage(page);
    }

    // Write PDF document to file
    try {
    	document.writeTo(new FileOutputStream(
                destination.getFileDescriptor()));
    } catch (IOException e) {
        callback.onWriteFailed(e.toString());
        return;
    } finally {
    	document.close();
    	document = null;
    }
    PageRange[] writtenPages = {PageRange.ALL_PAGES};
    // Signal the print framework the document is complete
    callback.onWriteFinished(writtenPages);
}
 
开发者ID:Defuera,项目名称:cards-app,代码行数:44,代码来源:PrintAdapter.java


注:本文中的android.print.PageRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。