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


Java BarcodeFormat.valueOf方法代码示例

本文整理汇总了Java中com.google.zxing.BarcodeFormat.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java BarcodeFormat.valueOf方法的具体用法?Java BarcodeFormat.valueOf怎么用?Java BarcodeFormat.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.BarcodeFormat的用法示例。


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

示例1: encodeContents

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
private boolean encodeContents(String data, Bundle bundle, String type, String formatString) {
    // Default to QR_CODE if no format given.
    format = null;
    if (formatString != null) {
        try {
            format = BarcodeFormat.valueOf(formatString);
        } catch (IllegalArgumentException iae) {
            // Ignore it then
        }
    }
    if (format == null || format == BarcodeFormat.QR_CODE) {
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(data, bundle, type);
    } else if (data != null && data.length() > 0) {
        contents = data;
        displayContents = data;
        title = "Text";
    }
    return contents != null && contents.length() > 0;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:QRCodeEncoder.java

示例2: buildHistoryItems

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
public List<HistoryItem> buildHistoryItems() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  List<HistoryItem> items = new ArrayList<>();
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    while (cursor.moveToNext()) {
      String text = cursor.getString(0);
      String display = cursor.getString(1);
      String format = cursor.getString(2);
      long timestamp = cursor.getLong(3);
      String details = cursor.getString(4);
      Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
      items.add(new HistoryItem(result, display, details));
    }
  } finally {
    close(cursor, db);
  }
  return items;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:23,代码来源:HistoryManager.java

示例3: buildHistoryItem

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
public HistoryItem buildHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    String text = cursor.getString(0);
    String display = cursor.getString(1);
    String format = cursor.getString(2);
    long timestamp = cursor.getLong(3);
    String details = cursor.getString(4);
    Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
    return new HistoryItem(result, display, details);
  } finally {
    close(cursor, db);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:20,代码来源:HistoryManager.java

示例4: encodeContentsFromZXingIntent

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
private void encodeContentsFromZXingIntent(Intent intent) {
    // Default to QR_CODE if no format given.
    String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
    format = null;
    if (formatString != null) {
        try {
            format = BarcodeFormat.valueOf(formatString);
        } catch (IllegalArgumentException iae) {
            // Ignore it then
        }
    }
    if (format == null || format == BarcodeFormat.QR_CODE) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        if (type != null && !type.isEmpty()) {
            this.format = BarcodeFormat.QR_CODE;
            encodeQRCodeContents(intent, type);
        }
    } else {
        String data = intent.getStringExtra(Intents.Encode.DATA);
        if (data != null && !data.isEmpty()) {
            contents = data;
            displayContents = data;
            title = activity.getString(R.string.contents_text);
        }
    }
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:27,代码来源:QRCodeEncoder.java

示例5: encodeContentsFromZXingIntent

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
private boolean encodeContentsFromZXingIntent(Intent intent) {
    // Default to QR_CODE if no format given.
    String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
    try {
        format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
        // Ignore it then
        format = null;
    }
    if (format == null || BarcodeFormat.QR_CODE.equals(format)) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        if (type == null || type.length() == 0) {
            return false;
        }
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(intent, type);
    } else {
        String data = intent.getStringExtra(Intents.Encode.DATA);
        if (data != null && data.length() > 0) {
            contents = data;
            displayContents = data;
            title = activity.getString(R.string.contents_text);
        }
    }
    return contents != null && contents.length() > 0;
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:27,代码来源:QRCodeEncoder.java

示例6: encodeContentsFromZXingIntent

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
private boolean encodeContentsFromZXingIntent(Intent intent) {
   // Default to QR_CODE if no format given.
  String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
  format = null;
  if (formatString != null) {
    try {
      format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
      // Ignore it then
    }
  }
  if (format == null || format == BarcodeFormat.QR_CODE) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    if (type == null || type.isEmpty()) {
      return false;
    }
    this.format = BarcodeFormat.QR_CODE;
    encodeQRCodeContents(intent, type);
  } else {
    String data = intent.getStringExtra(Intents.Encode.DATA);
    if (data != null && !data.isEmpty()) {
      contents = data;
      displayContents = data;
      title = activity.getString(R.string.contents_text);
    }
  }
  return contents != null && !contents.isEmpty();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:29,代码来源:QRCodeEncoder.java

示例7: onOptionsItemSelected

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_done) {
        if (barcodeText.getText().toString().equals("")){
            barcodeText.setError(getString(R.string.wrong_barcode_input));
        } else {
            if (Utils.isValidBarcode(barcodeText.getText().toString(), BarcodeFormat.valueOf(formatSpinner.getSelectedItem().toString()))){
                Intent intent = new Intent(ManualInputActivity.this, FinishActivity.class);
                Intent created = getIntent();
                Card card = new Card(created.getStringExtra("STORENAME"), barcodeText.getText().toString(), BarcodeFormat.valueOf(formatSpinner.getSelectedItem().toString()), 0, 0);
                intent.putExtra(Constants.INTENT_CARD_ARG, card);
                startActivityForResult(intent, Utils.ADD_STORE);
            } else {
                barcodeText.setError(getString(R.string.wrong_barcode_input));
            }
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:28,代码来源:ManualInputActivity.java

示例8: getContents

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
/**
 * Parse the data contained in the given stream and return a list of cards that was read from
 * that stream.
 *
 * @param stream A stream that gives access to the contents of the file to be read.
 * @return A list of cards that were found in the given file.
 * @throws IOException Whenever something goes wrong while reading the file.
 * @throws InvalidImportFile When the given fileUrl does not point to a valid Loyalty file.
 */
public List<Card> getContents(InputStream stream) throws IOException, InvalidImportFile {
    List<Card> output = new ArrayList<>();

    try {
        BufferedReader buffered = new BufferedReader(new InputStreamReader(stream));
        String line = buffered.readLine();
        while (line != null) {
            String[] rawData = line.split("\t");

            if (rawData.length != 4) {
                throw new InvalidImportFile();
            }

            // Keep compatibility with the previous version of Loyalty and thus keep 4 items
            // for every card (that's why index 3 is still used).
            Card temp = new Card(rawData[0], rawData[1], BarcodeFormat.valueOf(rawData[3]), 0, 0);
            output.add(temp);
            line = buffered.readLine();
        }
        buffered.close();
    } catch (IOException e) {
        throw new RuntimeException("Something went wrong while reading the file", e);
    }

    return output;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:36,代码来源:ExportManager.java

示例9: Card

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
public Card(Parcel in){
    this.id = in.readLong();
    this.name = in.readString();
    this.barcode = in.readString();
    this.imageLocation = in.readString();
    this.format = BarcodeFormat.valueOf(in.readString());
    this.lastSearched = in.readInt();
    this.hitCount = in.readInt();
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:10,代码来源:Card.java

示例10: buildCardFromCursor

import com.google.zxing.BarcodeFormat; //导入方法依赖的package包/类
/**
 * Uses all data at the current position in the given Cursor to build a Card object.
 *
 * @param cursor The Cursor from which all data is read and used to create the new Card.
 * @return A Card based upon the given Cursor's data.
 */
private Card buildCardFromCursor(Cursor cursor) {
    long cardID = cursor.getLong(cursor.getColumnIndex(DatabaseContract.COLUMN_ID));
    String name = cursor.getString(cursor.getColumnIndex(DatabaseContract.COLUMN_NAME));
    String barcode = cursor.getString(cursor.getColumnIndex(DatabaseContract.COLUMN_BARCODE));
    String barcodeFormat = cursor.getString(cursor.getColumnIndex(DatabaseContract.COLUMN_BARCODE_FORMAT));
    String imageURL = cursor.getString(cursor.getColumnIndex(DatabaseContract.COLUMN_IMAGE_URL));

    int lastSearched;
    if (cursor.getColumnIndex(DatabaseContract.COLUMN_LAST_SEARCHED) != -1) {
        lastSearched = cursor.getInt(cursor.getColumnIndex(DatabaseContract.COLUMN_LAST_SEARCHED));
    } else {
        lastSearched = 0;
    }

    int hitCount;
    if (cursor.getColumnIndex(DatabaseContract.COLUMN_HIT_COUNT) != -1) {
        hitCount = cursor.getInt(cursor.getColumnIndex(DatabaseContract.COLUMN_HIT_COUNT));
    } else {
        hitCount = 0;
    }

    Card output = new Card(name, barcode, imageURL, BarcodeFormat.valueOf(barcodeFormat), lastSearched, hitCount);
    output.setID(cardID);

    return output;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:33,代码来源:Database.java


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