<commit_before>/*
 * Copyright 2016 <NAME>
 *
 * 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.hippo.image.example;

/*
 * Created by Hippo on 9/16/2016.
 */

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Debug;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.hippo.image.BitmapDecoder;
import com.hippo.image.BitmapRegionDecoder;
import com.hippo.image.Image;
import com.hippo.image.ImageData;
import com.hippo.image.ImageInfo;
import com.hippo.image.ImageRenderer;
import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.MathUtils;

import junit.framework.Assert;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class TestActivity extends AppCompatActivity implements Runnable {

    private static final String LOG_TAG = TestActivity.class.getSimpleName();

    private static class ImageRes {

        public int id;
        public int width;
        public int height;
        public int format;
        public boolean opaque;
        public int frameCount;

        public ImageRes(int id, int width, int height, int format, boolean opaque, int frameCount) {
            this.id = id;
            this.width = width;
            this.height = height;
            this.format = format;
            this.opaque = opaque;
            this.frameCount = frameCount;
        }
    }

    private static final ImageRes[] IMAGES = {
            new ImageRes(R.raw.apng_rgb,  580,  584,  Image.FORMAT_PNG,  true,  1),
            new ImageRes(R.raw.apng_rgba, 100,  100,  Image.FORMAT_PNG,  false, 20),
            new ImageRes(R.raw.gif,       540,  540,  Image.FORMAT_GIF,  false, -1),
            new ImageRes(R.raw.jpeg_cmyk, 256,  256,  Image.FORMAT_JPEG, true,  1),
            new ImageRes(R.raw.jpeg_ycck, 1713, 2479, Image.FORMAT_JPEG, true,  1),
            new ImageRes(R.raw.png_rgba,  800,  600,  Image.FORMAT_PNG,  false,  1),
            new ImageRes(R.raw.png_test,  300,  300,  Image.FORMAT_PNG,  false,  1),
    };

    private static final int[] CONFIGS = {
            BitmapDecoder.CONFIG_AUTO,
            BitmapDecoder.CONFIG_RGB_565,
            BitmapDecoder.CONFIG_ARGB_8888,
    };

    private static final int[] RATIOS = {
            1, 2, 3, 4, 5, 6, 7, 8, 9,
    };


    private Resources mResources;
    private File mDir;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mResources = getResources();
        mDir = getExternalFilesDir("test");
        FileUtils.deleteContent(mDir);

        new Thread(this).start();
    }

    private String configToString(int config) {
        switch (config) {
            case BitmapDecoder.CONFIG_AUTO:
                return "AUTO";
            case BitmapDecoder.CONFIG_RGB_565:
                return "RGB_565";
            case BitmapDecoder.CONFIG_ARGB_8888:
                return "RGBA_8888";
            default:
                return "Unknown_config";
        }
    }

    @Override
    public void run() {
        test();
    }

    private void test() {
        testImage();
        //testBitmapDecoderDecodeInfo();
        //testBitmapDecoderDecode();
        //testBitmapRegionDecoderDecode();
        Log.d(LOG_TAG, "Test Done!");
    }

    private void testImage() {
        for (ImageRes res : IMAGES) {
            Log.d(LOG_TAG, "testImage " + mResources.getResourceEntryName(res.id));<commit_msg>Fix wrong references in app module<commit_after>/*
 * Copyright 2016 <NAME>
 *
 * 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.hippo.image.example;

/*
 * Created by Hippo on 9/16/2016.
 */

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Debug;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.hippo.image.BitmapDecoder;
import com.hippo.image.BitmapRegionDecoder;
import com.hippo.image.Image;
import com.hippo.image.ImageData;
import com.hippo.image.ImageInfo;
import com.hippo.image.ImageRenderer;
import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.MathUtils;

import junit.framework.Assert;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class TestActivity extends AppCompatActivity implements Runnable {

    private static final String LOG_TAG = TestActivity.class.getSimpleName();

    private static class ImageRes {

        public int id;
        public int width;
        public int height;
        public int format;
        public boolean opaque;
        public int frameCount;

        public ImageRes(int id, int width, int height, int format, boolean opaque, int frameCount) {
            this.id = id;
            this.width = width;
            this.height = height;
            this.format = format;
            this.opaque = opaque;
            this.frameCount = frameCount;
        }
    }

    private static final ImageRes[] IMAGES = {
            new ImageRes(R.raw.apng_rgb,  580,  584,  Image.FORMAT_PNG,  true,  1),
            new ImageRes(R.raw.apng_rgba, 100,  100,  Image.FORMAT_PNG,  false, 20),
            new ImageRes(R.raw.gif,       540,  540,  Image.FORMAT_GIF,  false, -1),
            new ImageRes(R.raw.jpeg_cmyk, 256,  256,  Image.FORMAT_JPEG, true,  1),
            new ImageRes(R.raw.jpeg_ycck, 1713, 2479, Image.FORMAT_JPEG, true,  1),
            new ImageRes(R.raw.png_rgba,  800,  600,  Image.FORMAT_PNG,  false,  1),
            new ImageRes(R.raw.png_test,  300,  300,  Image.FORMAT_PNG,  false,  1),
    };

    private static final int[] CONFIGS = {
            BitmapDecoder.CONFIG_AUTO,
            BitmapDecoder.CONFIG_RGB_565,
            BitmapDecoder.CONFIG_RGBA_8888,
    };

    private static final int[] RATIOS = {
            1, 2, 3, 4, 5, 6, 7, 8, 9,
    };


    private Resources mResources;
    private File mDir;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mResources = getResources();
        mDir = getExternalFilesDir("test");
        FileUtils.deleteContent(mDir);

        new Thread(this).start();
    }

    private String configToString(int config) {
        switch (config) {
            case BitmapDecoder.CONFIG_AUTO:
                return "AUTO";
            case BitmapDecoder.CONFIG_RGB_565:
                return "RGB_565";
            case BitmapDecoder.CONFIG_RGBA_8888:
                return "RGBA_8888";
            default:
                return "Unknown_config";
        }
    }

    @Override
    public void run() {
        test();
    }

    private void test() {
        testImage();
        //testBitmapDecoderDecodeInfo();
        //testBitmapDecoderDecode();
        //testBitmapRegionDecoderDecode();
        Log.d(LOG_TAG, "Test Done!");
    }

    private void testImage() {
        for (ImageRes res : IMAGES) {
            Log.d(LOG_TAG, "testImage " + mResources.getResourceEntryName(res.id));
{'fraction_non_alphanumeric': 0.09620677276534642, 'fraction_numerical': 0.023453392365681464, 'mean_word_length': 2.5415254237288134, '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': '6269831', 'n_tokens_mistral': 2610, 'n_tokens_neox': 2431, 'n_words': 670}