use of com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils in project SimplifyReader by chentao0707.
the class CaptureActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != RESULT_OK) {
return;
}
if (requestCode == IMAGE_PICKER_REQUEST_CODE) {
String imagePath = data.getStringExtra(CommonImagePickerDetailActivity.KEY_BUNDLE_RESULT_IMAGE_PATH);
if (!CommonUtils.isEmpty(imagePath)) {
ImageLoader.getInstance().loadImage("file://" + imagePath, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
String resultZxing = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL).decodeWithZxing(loadedImage);
String resultZbar = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL).decodeWithZbar(loadedImage);
if (!CommonUtils.isEmpty(resultZbar)) {
Bundle extras = new Bundle();
extras.putInt(DecodeThread.DECODE_MODE, DecodeUtils.DECODE_MODE_ZBAR);
handleDecode(resultZbar, extras);
} else if (!CommonUtils.isEmpty(resultZxing)) {
Bundle extras = new Bundle();
extras.putInt(DecodeThread.DECODE_MODE, DecodeUtils.DECODE_MODE_ZXING);
handleDecode(resultZxing, extras);
} else {
showToast(getResources().getString(R.string.tips_decode_null));
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
}
}
use of com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils in project SimplifyReader by chentao0707.
the class AboutUsActivity method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
mAboutArray = getResources().getStringArray(R.array.about_list);
mListViewDataAdapter = new ListViewDataAdapter<>(new ViewHolderCreator<AboutListEntity>() {
@Override
public ViewHolderBase<AboutListEntity> createViewHolder(int position) {
return new ViewHolderBase<AboutListEntity>() {
TextView mTitle;
TextView mSubTitle;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_about, null);
mTitle = ButterKnife.findById(convertView, R.id.list_item_about_title);
mSubTitle = ButterKnife.findById(convertView, R.id.list_item_about_sub_title);
return convertView;
}
@Override
public void showData(int position, AboutListEntity itemData) {
if (null != itemData) {
if (!CommonUtils.isEmpty(itemData.getTitle())) {
mTitle.setText(itemData.getTitle());
}
if (!CommonUtils.isEmpty(itemData.getSubTitle())) {
mSubTitle.setText(itemData.getSubTitle());
}
}
}
};
}
});
mListView.setAdapter(mListViewDataAdapter);
mItemData = new AboutListEntity();
mItemData.setTitle(mAboutArray[0]);
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
String version = String.format(getResources().getString(R.string.splash_version), packageInfo.versionName);
if (!CommonUtils.isEmpty(version)) {
mItemData.setSubTitle(version);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
mListViewDataAdapter.getDataList().add(mItemData);
mItemData = new AboutListEntity();
mItemData.setTitle(mAboutArray[1]);
mItemData.setSubTitle("https://github.com/SkillCollege");
mListViewDataAdapter.getDataList().add(mItemData);
mItemData = new AboutListEntity();
mItemData.setTitle(mAboutArray[2]);
mItemData.setSubTitle("https://github.com/SkillCollege/SimplifyReader");
mListViewDataAdapter.getDataList().add(mItemData);
mItemData = new AboutListEntity();
mItemData.setTitle(mAboutArray[3]);
mListViewDataAdapter.getDataList().add(mItemData);
mItemData = new AboutListEntity();
mItemData.setTitle(mAboutArray[4]);
mListViewDataAdapter.getDataList().add(mItemData);
mListViewDataAdapter.notifyDataSetChanged();
mPayCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
DecodeUtils decodeUtils = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL);
String url = decodeUtils.decodeWithZxing(BitmapFactory.decodeResource(getResources(), R.drawable.pay_qrcode));
if (!CommonUtils.isEmpty(url)) {
TLog.d(TAG_LOG, url);
intent.setData(Uri.parse(url));
}
startActivity(intent);
}
});
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle extras = new Bundle();
switch(position) {
case 0:
// version
break;
case 1:
// author
extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[1]);
extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true);
extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "https://github.com/SkillCollege");
readyGo(BaseWebActivity.class, extras);
break;
case 2:
// project index
extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[2]);
extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true);
extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "https://github.com/SkillCollege/SimplifyReader");
readyGo(BaseWebActivity.class, extras);
break;
case 3:
// project description
extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[3]);
extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, false);
extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "file:///android_asset/project_description.html");
readyGo(BaseWebActivity.class, extras);
break;
case 4:
// open source description
extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[4]);
extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, false);
extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "file:///android_asset/open_source.html");
readyGo(BaseWebActivity.class, extras);
break;
}
}
});
}
Aggregations