Пример #1
0
  /**
   * On button click, the check dialog will be brought up.
   *
   * @param button
   */
  public Check(Button button) {
    Activity activity = (Activity) button.getContext();

    // inflate the dialog view from the resource and create the dialog with
    // that view
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle("Check");
    LayoutInflater inflater = activity.getLayoutInflater();
    View v = inflater.inflate(R.layout.check_dialog, null);
    builder.setView(v);
    builder.setPositiveButton(
        R.string.ok,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // no special action when user clicks ok
          }
        });
    this.dialog = builder.create();

    // get references to the dynamic controls in the view
    this.checkTest = (TextView) v.findViewById(R.id.check_test);
    this.checkTargetProgress = (ProgressBar) v.findViewById(R.id.check_target_progress);
    this.checkActualProgress = (ProgressBar) v.findViewById(R.id.check_actual_progress);
    this.checkResult = (TextView) v.findViewById(R.id.check_result);

    this.maxRoll = button.getResources().getInteger(R.integer.max_roll);

    this.wrapper = new Wrapper();
    button.setOnClickListener(wrapper);
  }
  /**
   * Creates an instance of the activity by telling barcode scanner to scan using the {@link
   * BarcodeCallback} above and adding an {@link android.view.View.OnClickListener} to the Submit
   * {@link Button}
   *
   * @param savedInstanceState - Saved Instance Bundle
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scanning);

    barcodeScannerView = (CompoundBarcodeView) findViewById(R.id.zxing_barcode_scanner);
    barcodeScannerView.decodeContinuous(callback);
    etCodePinEntry = (EditText) findViewById(R.id.etCodePinEntry);

    Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
    btnSubmit.setContentDescription(
        btnSubmit.getResources().getString(R.string.content_description_submits));
    btnSubmit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            submit();
          }
        });

    ActionBar actionbar = getSupportActionBar();

    Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/ubuntu_l.ttf");
    SpannableString s = new SpannableString("hiTour");
    s.setSpan(new CustomTypefaceSpan("", font), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (actionbar != null) {
      actionbar.setTitle(s);
    }

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
        != PackageManager.PERMISSION_GRANTED) {
      Snackbar.make(
              barcodeScannerView, "Camera permission needed to scan points.", Snackbar.LENGTH_LONG)
          .show();
    }
  }