Java Code Examples for com.google.zxing.BarcodeFormat#valueOf()

The following examples show how to use com.google.zxing.BarcodeFormat#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryManager.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
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;
}
 
Example 2
Source File: QRCodeEncoder.java    From privacy-friendly-qr-scanner with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: HistoryManager.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example 4
Source File: HistoryManager.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: HistoryManager.java    From weex with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: QRCodeEncoder.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: HistoryManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example 8
Source File: QRCodeEncode.java    From Tok-Android with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 9
Source File: QRCodeEncoder.java    From android-quick-response-code with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 10
Source File: HistoryManager.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example 11
Source File: HistoryManager.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 12
Source File: QRCodeEncoder.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 13
Source File: QREncoder.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 14
Source File: QRCodeEncoder.java    From zom-android-matrix with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 15
Source File: QRCodeEncoder.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 16
Source File: HistoryManager.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
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);
  }
}
 
Example 17
Source File: HistoryManager.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 18
Source File: Converters.java    From privacy-friendly-qr-scanner with GNU General Public License v3.0 5 votes vote down vote up
@TypeConverter
public static BarcodeFormat fromText(String text) {
    try {
        return BarcodeFormat.valueOf(text);
    } catch (IllegalArgumentException | NullPointerException e) {
        return null;
    }
}
 
Example 19
Source File: QRCodeEncoder.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 20
Source File: QRCodeEncoder.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
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();
}