Ejemplo n.º 1
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   if (!exitActivity) {
     EPOSPrintSampleActivity.closePrinter();
   }
 }
Ejemplo n.º 2
0
  private void printImage() {
    if (selectImage == null) {
      ShowMsg.showError(R.string.errmsg_noimage, this);
      return;
    }

    Builder builder = null;
    String method = "";
    try {
      // create builder
      Intent intent = getIntent();
      method = "Builder";
      builder =
          new Builder(
              intent.getStringExtra("printername"),
              intent.getIntExtra("language", 0),
              getApplicationContext());

      // add command
      method = "addImage";
      builder.addImage(
          selectImage,
          0,
          0,
          Math.min(IMAGE_WIDTH_MAX, selectImage.getWidth()),
          selectImage.getHeight(),
          Builder.COLOR_1,
          getBuilderMode(),
          getBuilderHalftone(),
          getBuilderBrightness());

      // send builder data
      int[] status = new int[1];
      int[] battery = new int[1];
      try {
        Print printer = EPOSPrintSampleActivity.getPrinter();
        printer.sendData(builder, SEND_TIMEOUT, status, battery);
        ShowMsg.showStatus(EposException.SUCCESS, status[0], battery[0], this);
      } catch (EposException e) {
        ShowMsg.showStatus(e.getErrorStatus(), e.getPrinterStatus(), e.getBatteryStatus(), this);
      }
    } catch (Exception e) {
      ShowMsg.showException(e, method, this);
    }

    // remove builder
    if (builder != null) {
      try {
        builder.clearCommandBuffer();
        builder = null;
      } catch (Exception e) {
        builder = null;
      }
    }
  }
Ejemplo n.º 3
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image);

    // check close port
    Print printer = EPOSPrintSampleActivity.getPrinter();
    if (printer == null) {
      finish();
      return;
    } else {
      printer.setStatusChangeEventCallback(this);
      printer.setBatteryStatusChangeEventCallback(this);
    }

    // init printer list
    Spinner spinner = (Spinner) findViewById(R.id.spinner_colormode);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    adapter.add(getString(R.string.mode_mono));
    adapter.add(getString(R.string.mode_gray16));
    spinner.setAdapter(adapter);

    // init language list
    spinner = (Spinner) findViewById(R.id.spinner_halftonemethod);
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    adapter.add(getString(R.string.halftone_dither));
    adapter.add(getString(R.string.halftone_error_diffusion));
    adapter.add(getString(R.string.halftone_threshold));
    spinner.setAdapter(adapter);

    // init edit
    TextView textBrightness = (TextView) findViewById(R.id.editText_brightness);
    textBrightness.setText("1.0");

    // Registration ClickListener
    Button button = (Button) findViewById(R.id.button_print);
    button.setOnClickListener(this);

    button = (Button) findViewById(R.id.button_select);
    button.setOnClickListener(this);
  }