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


Java PrintAttributes类代码示例

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


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

示例1: printOrCreatePdfFromWebview

import android.print.PrintAttributes; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@SuppressWarnings("deprecation")
public PrintJob printOrCreatePdfFromWebview(WebView webview, String jobName) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Context c = webview.getContext();
        PrintDocumentAdapter printAdapter;
        PrintManager printManager = (PrintManager) c.getSystemService(Context.PRINT_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            printAdapter = webview.createPrintDocumentAdapter(jobName);
        } else {
            printAdapter = webview.createPrintDocumentAdapter();
        }
        if (printManager != null) {
            return printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
        }
    } else {
        Log.e(getClass().getName(), "ERROR: Method called on too low Android API version");
    }
    return null;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:21,代码来源:ShareUtilBase.java

示例2: genPdfFile

import android.print.PrintAttributes; //导入依赖的package包/类
private void genPdfFile() {
    PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);

    // Get a print adapter instance
    PrintDocumentAdapter printAdapter;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        printAdapter = mWebView.createPrintDocumentAdapter("my.pdf");
    } else {
        printAdapter = mWebView.createPrintDocumentAdapter();
    }

    // Create a print job with name and adapter instance
    String jobName = getString(R.string.app_name) + " Document";

    PrintAttributes attributes = new PrintAttributes.Builder()
            .setMediaSize(PrintAttributes.MediaSize.ISO_A4)
            .setResolution(new PrintAttributes.Resolution("id", Context.PRINT_SERVICE, 200, 200))
            .setColorMode(PrintAttributes.COLOR_MODE_COLOR)
            .setMinMargins(PrintAttributes.Margins.NO_MARGINS)
            .build();

    printManager.print(jobName, printAdapter, attributes);


}
 
开发者ID:REBOOTERS,项目名称:AndroidAnimationExercise,代码行数:26,代码来源:PdfActivity.java

示例3: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
@Override
public void onLayout(PrintAttributes oldAttributes,
                     PrintAttributes newAttributes,
                     CancellationSignal cancellationSignal,
                     LayoutResultCallback callback,
                     Bundle extras) {

    if (cancellationSignal.isCanceled()) {
        callback.onLayoutCancelled();
        return;
    }
    PrintDocumentInfo pdi = new PrintDocumentInfo.Builder("myFile")
            .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
            .build();

    callback.onLayoutFinished(pdi, true);
}
 
开发者ID:Swati4star,项目名称:Images-to-PDF,代码行数:18,代码来源:FilesAdapter.java

示例4: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
public final void onLayout(PrintAttributes paramPrintAttributes1, PrintAttributes paramPrintAttributes2, CancellationSignal paramCancellationSignal, PrintDocumentAdapter.LayoutResultCallback paramLayoutResultCallback, Bundle paramBundle)
{
  int i = 1;
  this.f = paramPrintAttributes2;
  if (paramCancellationSignal.isCanceled())
  {
    paramLayoutResultCallback.onLayoutCancelled();
    return;
  }
  if (this.b != null)
  {
    PrintDocumentInfo localPrintDocumentInfo = new PrintDocumentInfo.Builder(this.c).setContentType(i).setPageCount(i).build();
    if (!paramPrintAttributes2.equals(paramPrintAttributes1)) {}
    for (;;)
    {
      paramLayoutResultCallback.onLayoutFinished(localPrintDocumentInfo, i);
      return;
      int j = 0;
    }
  }
  this.a = new jo(this, paramCancellationSignal, paramPrintAttributes2, paramPrintAttributes1, paramLayoutResultCallback).execute(new Uri[0]);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:23,代码来源:jn.java

示例5: a

import android.print.PrintAttributes; //导入依赖的package包/类
public final void a(String paramString, Uri paramUri, x paramx)
{
  jl localjl = this.a;
  jn localjn = new jn(localjl, paramString, paramUri, null, localjl.d);
  PrintManager localPrintManager = (PrintManager)localjl.a.getSystemService("print");
  PrintAttributes.Builder localBuilder = new PrintAttributes.Builder();
  localBuilder.setColorMode(localjl.e);
  if (localjl.f == 1) {
    localBuilder.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE);
  }
  for (;;)
  {
    localPrintManager.print(paramString, localjn, localBuilder.build());
    return;
    if (localjl.f == 2) {
      localBuilder.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_PORTRAIT);
    }
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:20,代码来源:jh.java

示例6: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
public void onLayout(final PrintAttributes oldPrintAttributes, final PrintAttributes newPrintAttributes, final CancellationSignal cancellationSignal, android.print.PrintDocumentAdapter.LayoutResultCallback layoutresultcallback, Bundle bundle)
{
    boolean flag = true;
    mAttributes = newPrintAttributes;
    if (cancellationSignal.isCanceled())
    {
        layoutresultcallback.onLayoutCancelled();
        return;
    }
    if (mBitmap != null)
    {
        cancellationSignal = (new android.print.PrintDocumentInfo.Builder(jobName)).setContentType(1).setPageCount(1).build();
        if (newPrintAttributes.equals(oldPrintAttributes))
        {
            flag = false;
        }
        layoutresultcallback.onLayoutFinished(cancellationSignal, flag);
        return;
    } else
    {
        mLoadBitmap = (layoutresultcallback. new PrintHelperKitkat._cls2._cls1()).execute(new Uri[0]);
        return;
    }
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:25,代码来源:PrintHelperKitkat$2$1.java

示例7: onStartPrinterDiscovery

import android.print.PrintAttributes; //导入依赖的package包/类
@Override
public void onStartPrinterDiscovery(List<PrinterId> printers) {
    Log.d(TAG, "onStartPrinterDiscovery()");
    for (PrinterId id : printers) {
        Log.d(TAG, "printerId:" + id.getLocalId());
    }
    List<PrinterInfo> addPrinters = new ArrayList<PrinterInfo>();
    PrinterId printerId = mPrintService.generatePrinterId(PRINTER_ID);
    
    PrinterInfo.Builder builder = new PrinterInfo.Builder(printerId,
            "Dropbox Printer", PrinterInfo.STATUS_IDLE);
    
    PrinterCapabilitiesInfo.Builder capBuilder =
      new PrinterCapabilitiesInfo.Builder(printerId);
    capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_A4, true);
    capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_B5, false);
    capBuilder.addResolution(new PrintAttributes.Resolution(
            "Default", "default resolution", 600, 600), true);
    capBuilder.setColorModes(PrintAttributes.COLOR_MODE_COLOR
            | PrintAttributes.COLOR_MODE_MONOCHROME,
            PrintAttributes.COLOR_MODE_COLOR);
    
    builder.setCapabilities(capBuilder.build());
    addPrinters.add(builder.build());
    addPrinters(addPrinters);
}
 
开发者ID:sys1yagi,项目名称:DropboxPrintService,代码行数:27,代码来源:DropboxPrinterDiscoverySession.java

示例8: ThermalPrinterDiscoverySession

import android.print.PrintAttributes; //导入依赖的package包/类
ThermalPrinterDiscoverySession(PrinterInfo printerInfo) {
    PrinterCapabilitiesInfo capabilities =
            new PrinterCapabilitiesInfo.Builder(printerInfo.getId())
                  .addMediaSize(PrintAttributes.MediaSize.ISO_A5, true)
                  .addResolution(new PrintAttributes.Resolution("1234","Default",200,200), true)
                  .setColorModes(PrintAttributes.COLOR_MODE_MONOCHROME, PrintAttributes.COLOR_MODE_MONOCHROME)
            .build();
    this.printerInfo = new PrinterInfo.Builder(printerInfo)
            .setCapabilities(capabilities)
            .build();
}
 
开发者ID:serrexlabs,项目名称:thermal-printer-service,代码行数:12,代码来源:ThermalPrintService.java

示例9: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
public final void onLayout(PrintAttributes paramPrintAttributes1, PrintAttributes paramPrintAttributes2, CancellationSignal paramCancellationSignal, PrintDocumentAdapter.LayoutResultCallback paramLayoutResultCallback, Bundle paramBundle)
{
  int i = 1;
  this.a = paramPrintAttributes2;
  PrintDocumentInfo localPrintDocumentInfo = new PrintDocumentInfo.Builder(this.b).setContentType(i).setPageCount(i).build();
  if (!paramPrintAttributes2.equals(paramPrintAttributes1)) {}
  for (;;)
  {
    paramLayoutResultCallback.onLayoutFinished(localPrintDocumentInfo, i);
    return;
    int j = 0;
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:14,代码来源:jm.java

示例10: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
@Override
public void onLayout(
        PrintAttributes oldAttributes,
        PrintAttributes newAttributes,
        CancellationSignal cancellationSignal,
        PrintDocumentAdapterWrapper.LayoutResultCallbackWrapper callback,
        Bundle metadata) {
    // NOTE: Chrome printing just supports one DPI, whereas Android has both vertical and
    // horizontal.  These two values are most of the time same, so we just pass one of them.
    mDpi = newAttributes.getResolution().getHorizontalDpi();
    mMediaSize = newAttributes.getMediaSize();

    mNeedNewPdf = !newAttributes.equals(oldAttributes);

    mOnLayoutCallback = callback;
    // We don't want to stack Chromium with multiple PDF generation operations before
    // completion of an ongoing one.
    // TODO(cimamoglu): Whenever onLayout is called, generate a new PDF with the new
    //                  parameters. Hence, we can get the true number of pages.
    if (mPrintingState == PRINTING_STATE_STARTED_FROM_ONLAYOUT) {
        // We don't start a new Chromium PDF generation operation if there's an existing
        // onLayout going on. Use the last known valid page count.
        pageCountEstimationDone(mLastKnownMaxPages);
    } else if (mPrintingState == PRINTING_STATE_STARTED_FROM_ONWRITE) {
        callback.onLayoutFailed(mErrorMessage);
        resetCallbacks();
    } else if (mPrintable.print()) {
        mPrintingState = PRINTING_STATE_STARTED_FROM_ONLAYOUT;
    } else {
        callback.onLayoutFailed(mErrorMessage);
        resetCallbacks();
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:34,代码来源:PrintingControllerImpl.java

示例11: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
@Override
public void onLayout(
        PrintAttributes oldAttributes,
        PrintAttributes newAttributes,
        CancellationSignal cancellationSignal,
        LayoutResultCallback callback,
        Bundle metadata) {
    mPdfGenerator.onLayout(oldAttributes, newAttributes, cancellationSignal,
            new LayoutResultCallbackWrapperImpl(callback), metadata);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:PrintDocumentAdapterWrapper.java

示例12: onLayout

import android.print.PrintAttributes; //导入依赖的package包/类
public void onLayout(PrintAttributes printattributes, PrintAttributes printattributes1, CancellationSignal cancellationsignal, android.print..LayoutResultCallback layoutresultcallback, Bundle bundle)
{
    boolean flag = true;
    mAttributes = printattributes1;
    cancellationsignal = (new android.print.ilder(val$jobName)).setContentType(1).setPageCount(1).build();
    if (printattributes1.equals(printattributes))
    {
        flag = false;
    }
    layoutresultcallback.onLayoutFinished(cancellationsignal, flag);
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:12,代码来源:PrintHelperKitkat$1.java

示例13: createWebPrintJob

import android.print.PrintAttributes; //导入依赖的package包/类
private void createWebPrintJob(WebView webView) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        new UIHelper(this).showToast(R.string.min_19);
        return;
    } else {
        // Get a PrintManager instance
        PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);

        // Get a print adapter instance
        PrintDocumentAdapter printAdapter;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            printAdapter = webView.createPrintDocumentAdapter(getString(R.string.asset_allocation));
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
            printAdapter = webView.createPrintDocumentAdapter();
        } else {
            // to satisfy lint.
            return;
        }

        // Create a print job with name and adapter instance
        String jobName = getString(R.string.app_name) + " Document";
        // PrintJob printJob =
        printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
    }
}
 
开发者ID:moneymanagerex,项目名称:android-money-manager-ex,代码行数:26,代码来源:AssetAllocationReportActivity.java

示例14: mockFinalAndroidFrameworkClass

import android.print.PrintAttributes; //导入依赖的package包/类
@Test
public void mockFinalAndroidFrameworkClass() throws Exception {
    // PrintAttributes is final
    PrintAttributes mockAttributes = mock(PrintAttributes.class);

    assertEquals(0, mockAttributes.getColorMode());

    when(mockAttributes.getColorMode()).thenReturn(42);

    assertEquals(42, mockAttributes.getColorMode());
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:12,代码来源:MockFinal.java

示例15: print

import android.print.PrintAttributes; //导入依赖的package包/类
static void print(final Context context, final long poemId) {
    new AsyncTask<Void, Void, PoemCursor>() {

        @Override
        protected PoemCursor doInBackground(Void... params) {
            final PoemSelection poemSelection = new PoemSelection().id(poemId);
            PoemCursor cursor = poemSelection.query(context.getContentResolver());
            if (cursor.moveToFirst()) {
                return cursor;
            }
            return null;
        }

        @Override
        protected void onPostExecute(final PoemCursor poemCursor) {
            if (poemCursor == null) return;
            final WebView webView = new WebView(context);
            final String title = poemCursor.getTitle();
            webView.setWebViewClient(new WebViewClient() {
                @Override
                public void onPageFinished(WebView view, String url) {
                    super.onPageFinished(view, url);
                    @SuppressWarnings("deprecation")
                    PrintDocumentAdapter printDocumentAdapter =
                            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? webView.createPrintDocumentAdapter(title)
                                    : webView.createPrintDocumentAdapter();
                    PrintAttributes printAttributes = new PrintAttributes.Builder().build();
                    PrintManager printManager = (PrintManager) context.getSystemService(Context.PRINT_SERVICE);
                    printManager.print(title, printDocumentAdapter, printAttributes);
                }
            });
            try {
                String preContent = poemCursor.getPreContent();
                if (preContent == null) preContent = "";
                String formattedText = context.getString(R.string.print_preview_html,
                        poemCursor.getTitle(),
                        preContent,
                        poemCursor.getContent(),
                        Poems.getPoemNumberString(context, poemCursor),
                        Poems.getLocationDateString(context, poemCursor));
                webView.loadDataWithBaseURL(null, formattedText, "text/html", "UTF-8", null);
            } finally {
                poemCursor.close();
            }
        }
    }.execute();

}
 
开发者ID:caarmen,项目名称:PalidaMuerte,代码行数:49,代码来源:PoemPrinter.java


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