當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。