本文整理汇总了Java中com.journeyapps.barcodescanner.BarcodeEncoder类的典型用法代码示例。如果您正苦于以下问题:Java BarcodeEncoder类的具体用法?Java BarcodeEncoder怎么用?Java BarcodeEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BarcodeEncoder类属于com.journeyapps.barcodescanner包,在下文中一共展示了BarcodeEncoder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createQRImage
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
private Bitmap createQRImage(String address) {
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
int imageSize = (int) (size.x * QR_IMAGE_WIDTH_RATIO);
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(
address,
BarcodeFormat.QR_CODE,
imageSize,
imageSize,
null);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
return barcodeEncoder.createBitmap(bitMatrix);
} catch (Exception e) {
Toast.makeText(this, getString(R.string.error_fail_generate_qr), Toast.LENGTH_SHORT)
.show();
}
return null;
}
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:20,代码来源:MyAddressActivity.java
示例2: onCreate
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
/**
* Standard Android on create method that gets called when the activity
* initialized.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_generate);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
text = (EditText) findViewById(R.id.txtQR);
image = (ImageView) findViewById(R.id.image);
//Setup the Spinner Menu for the different formats
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.formats_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
//If the device were rotated then restore information
if(savedInstanceState != null){
text2Qr = (String) savedInstanceState.get(STATE_TEXT);
text.setText(text2Qr);
}
// Get intent, action and MINE type and check if the intent was started by a share to modul from an other app
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null){
if("text/plain".equals(type)){
handleSendText(intent); //call method to handle sended text
}
}
//OnClickListener for the "+" Button and functionality
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
text2Qr = text.getText().toString().trim();
if(text2Qr.equals("")){
Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_text_first), Toast.LENGTH_SHORT).show();
} else {
multiFormatWriter = new MultiFormatWriter();
try{
BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, format, 500,500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
image.setImageBitmap(bitmap);
} catch (Exception e){
Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
}
}
}
});
}
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:64,代码来源:GenerateActivity.java
示例3: CreateQR
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
public Bitmap CreateQR(String str){
Bitmap bitmap = null;
BitMatrix result = null;
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
try {
result = multiFormatWriter.encode(str, BarcodeFormat.QR_CODE, 200, 200);
// 使用 ZXing Android Embedded 要写的代码
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(result);
} catch (WriterException e){
e.printStackTrace();
} catch (IllegalArgumentException iae){ // ?
return null;
}
// 如果不使用 ZXing Android Embedded 的话,要写的代码
// int w = result.getWidth();
// int h = result.getHeight();
// int[] pixels = new int[w * h];
// for (int y = 0; y < h; y++) {
// int offset = y * w;
// for (int x = 0; x < w; x++) {
// pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
// }
// }
// bitmap = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
// bitmap.setPixels(pixels,0,100,0,0,w,h);
return bitmap;
}
开发者ID:yzzslow0,项目名称:Ec2m,代码行数:32,代码来源:QrUtil.java
示例4: doInBackground
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Void... params) {
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
try {
int width = 1024;
int height = 1024;
switch (format) {
case AZTEC:
break;
case CODABAR:
height = (int) (width * 0.4f);
break;
case CODE_39:
height = (int) (width * 0.4f);
break;
case CODE_93:
break;
case CODE_128:
height = (int) (width * 0.4f);
break;
case DATA_MATRIX:
break;
case EAN_8:
height = (int) (width * 0.4f);
break;
case EAN_13:
height = (int) (width * 0.4f);
break;
case ITF:
height = (int) (width * 0.4f);
break;
case MAXICODE:
break;
case PDF_417:
height = (int) (width * 0.4f);
break;
case QR_CODE:
break;
case RSS_14:
break;
case RSS_EXPANDED:
break;
case UPC_A:
break;
case UPC_E:
break;
case UPC_EAN_EXTENSION:
break;
}
BitMatrix bitMatrix = multiFormatWriter.encode(data, format, width, height);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
return barcodeEncoder.createBitmap(bitMatrix);
} catch (Exception e) {
e.printStackTrace();
this.error = e;
}
return null;
}
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:59,代码来源:BarcodeEncodedFragment.java
示例5: onCreate
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_barcode_generate);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
text = (EditText) findViewById(R.id.tfBarcode);
image = (ImageView) findViewById(R.id.image);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Setup the Spinner Menu for the different formats
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.barcode_formats_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
//If the device were rotated then restore information
if(savedInstanceState != null){
text2Barcode = (String) savedInstanceState.get(STATE_TEXT);
text.setText(text2Barcode);
}
// Get intent, action and MINE type and check if the intent was started by a share to modul from an other app
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null){
if("text/plain".equals(type)){
handleSendText(intent); //call method to handle sended text
}
}
//OnClickListener for the "+" Button and functionality
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
text2Barcode = text.getText().toString().trim();
if(text2Barcode.equals("")){
Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_text_first), Toast.LENGTH_SHORT).show();
} else {
multiFormatWriter = new MultiFormatWriter();
try{
BitMatrix bitMatrix = multiFormatWriter.encode(text2Barcode, format, 500,500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
image.setImageBitmap(bitmap);
} catch (Exception e){
Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
}
}
}
});
}
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:60,代码来源:BarcodeGenerateActivity.java
示例6: onCreate
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geo_generator);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
tfLatitude = (EditText) findViewById(R.id.tfLatitude);
tfLongtitude = (EditText) findViewById(R.id.tfLongtitude);
cbLatitude = (CheckBox) findViewById(R.id.cbLatitude);
cbLongtitude = (CheckBox) findViewById(R.id.cbLongtitude);
image = (ImageView) findViewById(R.id.image);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Setup the Spinner Menu for the different formats
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.formats_geo_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
//If the device were rotated then restore information
if(savedInstanceState != null){
latitude = (String) savedInstanceState.get(STATE_LATITUDE);
tfLatitude.setText(latitude);
longtitude = (String) savedInstanceState.get(STATE_LONGTITUDE);
tfLongtitude.setText(longtitude);
north = (Boolean) savedInstanceState.get(STATE_NORTH);
if(!north){
cbLatitude.setChecked(false);
}
east = (Boolean) savedInstanceState.get(STATE_EAST);
if(!east){
cbLongtitude.setChecked(false);
}
}
//OnClickListener for the "+" Button and functionality
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
latitude = tfLatitude.getText().toString().trim();
longtitude = tfLongtitude.getText().toString().trim();
if(latitude.equals("") || longtitude.equals("")){
Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_geo_first), Toast.LENGTH_SHORT).show();
} else {
multiFormatWriter = new MultiFormatWriter();
try{
if(north && east) {
geo = "geo:" + latitude + "," + longtitude;
} else if (!east && north){
geo = "geo:" + latitude + ",-" + longtitude;
} else if (!north && east){
geo = "geo:-" + latitude + "," + longtitude;
} else {
geo = "geo:-" + latitude + ",-" + longtitude;
}
BitMatrix bitMatrix = multiFormatWriter.encode(geo, format, 500,500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
image.setImageBitmap(bitmap);
} catch (Exception e){
Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
}
}
}
});
}
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:70,代码来源:GeoGeneratorActivity.java
示例7: onCreate
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
/**
* Standard Android on create method that gets called when the activity
* initialized.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_generator);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
text = (EditText) findViewById(R.id.txtQR);
image = (ImageView) findViewById(R.id.image);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Setup the Spinner Menu for the different formats
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.text_formats_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
//If the device were rotated then restore information
if(savedInstanceState != null){
text2Qr = (String) savedInstanceState.get(STATE_TEXT);
text.setText(text2Qr);
}
// Get intent, action and MINE type and check if the intent was started by a share to modul from an other app
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null){
if("text/plain".equals(type)){
handleSendText(intent); //call method to handle sended text
}
}
//OnClickListener for the "+" Button and functionality
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
text2Qr = text.getText().toString().trim();
if(text2Qr.equals("")){
Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_text_first), Toast.LENGTH_SHORT).show();
} else {
multiFormatWriter = new MultiFormatWriter();
try{
BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, format, 500,500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
image.setImageBitmap(bitmap);
} catch (Exception e){
Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
}
}
}
});
}
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:65,代码来源:TextGeneratorActivity.java
示例8: onCreate
import com.journeyapps.barcodescanner.BarcodeEncoder; //导入依赖的package包/类
/**
* Standard Android on create method that gets called when the activity
* initialized.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vcard_generator);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
initializeInputFields();
image = (ImageView) findViewById(R.id.image);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Setup the Spinner Menu for the different formats
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.text_formats_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
if(savedInstanceState != null){
text2Qr = (String[]) savedInstanceState.get(STATE_TEXT);
recoverOldValues();
}
//OnClickListener for the "+" Button and functionality
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
insertValuesIntoArray();
if(text2Qr[0].equals("") && text2Qr[1].equals("")){
Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_fn_or_name_first), Toast.LENGTH_SHORT).show();
} else {
multiFormatWriter = new MultiFormatWriter();
try{
buildVCardCode();
BitMatrix bitMatrix = multiFormatWriter.encode(vcardCode, format, 500,500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
image.setImageBitmap(bitmap);
} catch (Exception e){
Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
}
}
}
});
}
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:54,代码来源:VCardGeneratorActivity.java
注:本文中的com.journeyapps.barcodescanner.BarcodeEncoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论