// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
// 
//     public WriterException() {
//     }
// 
//     public WriterException(String message) {
//         super(message);
//     }
// 
//     public WriterException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
// 
//     private static final int WHITE = 0xFFFFFFFF;
//     private static final int BLACK = 0xFF000000;
// 
//     private int dimension = Integer.MIN_VALUE;
//     private String displayContents = null;
//     private String contents = null;
//     private Map<EncodeHintType, Object> hints = null;
//     private boolean encoded = false;
// 
//     public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
//         this(null, dimension, hints);
//     }
// 
//     public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
//         this.dimension = dimension;
//         this.encoded = encodeContents(data);
//         this.hints = hints;
//     }
// 
//     public String getContents() {
//         return contents;
//     }
// 
//     public String getDisplayContents() {
//         return displayContents;
//     }
// 
//     private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
//         Object foreground = hints.get(key);
//         if (foreground == null || !(foreground instanceof Integer)) {
//             return defaultColor;
//         } else {
//             return ((Integer) foreground);
//         }
//     }
// 
//     public void setData(String data) {
//         encoded = encodeContents(data);
//     }
// 
//     public void setDimension(int dimension) {
//         this.dimension = dimension;
//     }
// 
//     public Bitmap encodeAsBitmap() throws WriterException {
//         if (!encoded)
//             return null;
// 
//         Map<EncodeHintType, Object> hints = this.hints;
//         if (hints == null)
//             hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
// 
//         // Add encoding if it exits
//         String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
//         if (encoding == null)
//             encoding = guessAppropriateEncoding(contents);
//         if (encoding != null) {
//             hints.put(EncodeHintType.CHARACTER_SET, encoding);
//         }
//         QRCodeWriter writer = new QRCodeWriter();
//         BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
//         int width = result.getWidth();
//         int height = result.getHeight();
//         int[] pixels = new int[width * height];
// 
//         int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
//         int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
// 
//         // All are 0, or black, by default
//         for (int y = 0; y < height; y++) {
//             int offset = y * width;
//             for (int x = 0; x < width; x++) {
//                 pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
//             }
//         }
// 
//         Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
//         bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
//         return bitmap;
//     }
// 
//     private boolean encodeContents(String data) {
//         contents = data;
//         displayContents = data;
//         return contents != null && contents.length() > 0;
//     }
// 
//     private static String guessAppropriateEncoding(CharSequence contents) {
//         // Very crude at the moment
//         for (int i = 0; i < contents.length(); i++) {
//             if (contents.charAt(i) > 0xFF) {
//                 return "UTF-8";
//             }
//         }
//         return null;
//     }
// 
//     private static String trim(String s) {
//         if (s == null) {
//             return null;
//         }
//         String result = s.trim();
//         return result.length() == 0 ? null : result;
//     }
// 
//     private static String escapeMECARD(String input) {
//         if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
//             return input;
//         }
//         int length = input.length();
//         StringBuilder result = new StringBuilder(length);
//         for (int i = 0; i < length; i++) {
//             char c = input.charAt(i);
//             if (c == ':' || c == ';') {
//                 result.append('\\');
//             }
//             result.append(c);
//         }
//         return result.toString();
//     }
// }


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 android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;
     */
    public static class PlaceholderFragment extends Fragment {

        private ImageView mQRCodeImage;
        private TextView mQRCodeText;

        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);
            mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
        }

        @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();
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
// 
//     public WriterException() {
//     }
// 
//     public WriterException(String message) {
//         super(message);
//     }
// 
//     public WriterException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
// 
//     private static final int WHITE = 0xFFFFFFFF;
//     private static final int BLACK = 0xFF000000;
// 
//     private int dimension = Integer.MIN_VALUE;
//     private String displayContents = null;
//     private String contents = null;
//     private Map<EncodeHintType, Object> hints = null;
//     private boolean encoded = false;
// 
//     public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
//         this(null, dimension, hints);
//     }
// 
//     public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
//         this.dimension = dimension;
//         this.encoded = encodeContents(data);
//         this.hints = hints;
//     }
// 
//     public String getContents() {
//         return contents;
//     }
// 
//     public String getDisplayContents() {
//         return displayContents;
//     }
// 
//     private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
//         Object foreground = hints.get(key);
//         if (foreground == null || !(foreground instanceof Integer)) {
//             return defaultColor;
//         } else {
//             return ((Integer) foreground);
//         }
//     }
// 
//     public void setData(String data) {
//         encoded = encodeContents(data);
//     }
// 
//     public void setDimension(int dimension) {
//         this.dimension = dimension;
//     }
// 
//     public Bitmap encodeAsBitmap() throws WriterException {
//         if (!encoded)
//             return null;
// 
//         Map<EncodeHintType, Object> hints = this.hints;
//         if (hints == null)
//             hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
// 
//         // Add encoding if it exits
//         String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
//         if (encoding == null)
//             encoding = guessAppropriateEncoding(contents);
//         if (encoding != null) {
//             hints.put(EncodeHintType.CHARACTER_SET, encoding);
//         }
//         QRCodeWriter writer = new QRCodeWriter();
//         BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
//         int width = result.getWidth();
//         int height = result.getHeight();
//         int[] pixels = new int[width * height];
// 
//         int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
//         int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
// 
//         // All are 0, or black, by default
//         for (int y = 0; y < height; y++) {
//             int offset = y * width;
//             for (int x = 0; x < width; x++) {
//                 pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
//             }
//         }
// 
//         Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
//         bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
//         return bitmap;
//     }
// 
//     private boolean encodeContents(String data) {
//         contents = data;
//         displayContents = data;
//         return contents != null && contents.length() > 0;
//     }
// 
//     private static String guessAppropriateEncoding(CharSequence contents) {
//         // Very crude at the moment
//         for (int i = 0; i < contents.length(); i++) {
//             if (contents.charAt(i) > 0xFF) {
//                 return "UTF-8";
//             }
//         }
//         return null;
//     }
// 
//     private static String trim(String s) {
//         if (s == null) {
//             return null;
//         }
//         String result = s.trim();
//         return result.length() == 0 ? null : result;
//     }
// 
//     private static String escapeMECARD(String input) {
//         if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
//             return input;
//         }
//         int length = input.length();
//         StringBuilder result = new StringBuilder(length);
//         for (int i = 0; i < length; i++) {
//             char c = input.charAt(i);
//             if (c == ':' || c == ';') {
//                 result.append('\\');
//             }
//             result.append(c);
//         }
//         return result.toString();
//     }
// }


// Path: example/src/main/java/com/justyoyo/contrast/example/DemoActivity.java
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 android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;

     */
    public static class PlaceholderFragment extends Fragment {

        private ImageView mQRCodeImage;
        private TextView mQRCodeText;

        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);
            mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
        }

        @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) {