Android Open Source - Contrast Demo Activity






From Project

Back to project page Contrast.

License

The source code is released under:

Apache License

If you think the Android project Contrast listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.justyoyo.contrast.example;
//w w w  . ja  v a  2 s.  c  o m
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;

public class DemoActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        private ImageView mQRCodeImage;

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            return inflater.inflate(R.layout.fragment_demo, container, false);
        }

        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            super.onViewCreated(view, savedInstanceState);
            mQRCodeImage = (ImageView) view.findViewById(R.id.qrcode_image);
        }

        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            float size = 192f * getResources().getDisplayMetrics().density;
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder("4040111111111111", (int) size, null);
            Bitmap bitmap = null;
            try {
                bitmap = qrCodeEncoder.encodeAsBitmap();
            } catch (WriterException e) {
                e.printStackTrace();
            }
            finally {
                mQRCodeImage.setImageBitmap(bitmap);
            }
        }
    }

}




Java Source Code List

com.justyoyo.contrast.BarcodeFormat.java
com.justyoyo.contrast.EncodeHintType.java
com.justyoyo.contrast.FormatException.java
com.justyoyo.contrast.ReaderException.java
com.justyoyo.contrast.WriterException.java
com.justyoyo.contrast.Writer.java
com.justyoyo.contrast.common.BitArray.java
com.justyoyo.contrast.common.BitMatrix.java
com.justyoyo.contrast.common.CharacterSetECI.java
com.justyoyo.contrast.common.reedsolomon.GenericGFPoly.java
com.justyoyo.contrast.common.reedsolomon.GenericGF.java
com.justyoyo.contrast.common.reedsolomon.ReedSolomonEncoder.java
com.justyoyo.contrast.example.DemoActivity.java
com.justyoyo.contrast.qrcode.QRCodeEncoder.java
com.justyoyo.contrast.qrcode.QRCodeWriter.java
com.justyoyo.contrast.qrcode.decoder.ErrorCorrectionLevel.java
com.justyoyo.contrast.qrcode.decoder.FormatInformation.java
com.justyoyo.contrast.qrcode.decoder.Mode.java
com.justyoyo.contrast.qrcode.decoder.Version.java
com.justyoyo.contrast.qrcode.encoder.BlockPair.java
com.justyoyo.contrast.qrcode.encoder.ByteMatrix.java
com.justyoyo.contrast.qrcode.encoder.Encoder.java
com.justyoyo.contrast.qrcode.encoder.MaskUtil.java
com.justyoyo.contrast.qrcode.encoder.MatrixUtil.java
com.justyoyo.contrast.qrcode.encoder.QRCode.java