Search in sources :

Example 1 with DecodeUtils

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) {
                }
            });
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) Bundle(android.os.Bundle) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) DecodeUtils(com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View)

Example 2 with DecodeUtils

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;
            }
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) PackageInfo(android.content.pm.PackageInfo) Bundle(android.os.Bundle) Intent(android.content.Intent) BaseWebActivity(com.github.obsessive.library.base.BaseWebActivity) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AboutListEntity(com.github.obsessive.simplifyreader.bean.AboutListEntity) PackageManager(android.content.pm.PackageManager) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator) DecodeUtils(com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils)

Aggregations

Bundle (android.os.Bundle)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 InjectView (butterknife.InjectView)2 DecodeUtils (com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils)2 Intent (android.content.Intent)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Bitmap (android.graphics.Bitmap)1 LayoutInflater (android.view.LayoutInflater)1 SurfaceView (android.view.SurfaceView)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ViewHolderBase (com.github.obsessive.library.adapter.ViewHolderBase)1 ViewHolderCreator (com.github.obsessive.library.adapter.ViewHolderCreator)1 BaseWebActivity (com.github.obsessive.library.base.BaseWebActivity)1 AboutListEntity (com.github.obsessive.simplifyreader.bean.AboutListEntity)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)1