<commit_before>/*
 * Copyright (c) 2017 - present, CV4J Contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cv4j.app.fragment;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.cv4j.app.R;
import com.cv4j.app.app.BaseFragment;
import com.cv4j.core.datamodel.CV4JImage;
import com.cv4j.core.datamodel.Rect;
import com.cv4j.image.util.QRCodeScanner;
import com.safframework.injectview.Injector;
import com.safframework.injectview.annotations.InjectView;
import com.safframework.injectview.annotations.OnClick;

/**
 * Created by <NAME> on 2017/8/19.
 */

public class QRFragment extends BaseFragment {

    @InjectView(R.id.image)
    ImageView image;

    @InjectView(R.id.detect_btn)
    Button detectButton;

    private final static String QR_INDEX = "index";

    private int mIndex;

    private Bitmap bitmap;

    public static QRFragment newInstance(int index) {
        Bundle args = new Bundle();
        args.putInt(QR_INDEX, index);
        QRFragment fragment = new QRFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            mIndex = bundle.getInt(QR_INDEX);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_qr, container, false);
        Injector.injectInto(this, v);

        initData();
        return v;
    }

    private void initData() {

        switch(mIndex) {

            case 1:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_1);
                break;

            case 2:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_applepay);
                break;

            case 3:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_jiazhigang);
                break;

            case 4:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_tony);
                break;

            default:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_1);
                break;
        }
<commit_msg>update demo<commit_after>/*
 * Copyright (c) 2017 - present, CV4J Contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cv4j.app.fragment;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.cv4j.app.R;
import com.cv4j.app.app.BaseFragment;
import com.cv4j.core.datamodel.CV4JImage;
import com.cv4j.core.datamodel.Rect;
import com.cv4j.image.util.QRCodeScanner;
import com.safframework.injectview.Injector;
import com.safframework.injectview.annotations.InjectView;
import com.safframework.injectview.annotations.OnClick;

/**
 * Created by <NAME> on 2017/8/19.
 */

public class QRFragment extends BaseFragment {

    @InjectView(R.id.image)
    ImageView image;

    @InjectView(R.id.detect_btn)
    Button detectButton;

    private final static String QR_INDEX = "index";

    private int mIndex;

    private Bitmap bitmap;

    public static QRFragment newInstance(int index) {
        Bundle args = new Bundle();
        args.putInt(QR_INDEX, index);
        QRFragment fragment = new QRFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            mIndex = bundle.getInt(QR_INDEX);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_qr, container, false);
        Injector.injectInto(this, v);

        initData();
        return v;
    }

    private void initData() {

        switch(mIndex) {

            case 0:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_1);
                break;

            case 1:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_applepay);
                break;

            case 2:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_jiazhigang);
                break;

            case 3:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_tony);
                break;

            default:
                bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.qr_1);
                break;
        }

{'fraction_non_alphanumeric': 0.09188168659534299, 'fraction_numerical': 0.009125235997482694, 'mean_word_length': 2.824909747292419, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6033256', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1727, 'n_words': 465}