<commit_before>package me.foxaice.smartlight.fragments.modes.music_mode.waveformview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

import me.foxaice.smartlight.R;
import me.foxaice.smartlight.fragments.modes.music_mode.model.IMusicInfo;

public class WaveFormView extends AppCompatImageView {
    private static final int STROKE_WIDTH_DP = 2;
    private static final int PADDING_DP = 16;
    private Paint mStrokePaint;
    private Paint mFillPaint;
    private Paint mWaveFormPaint;
    private int mStrokeWidthPx;
    private float mLeftCanvasCoord;
    private float mTopCanvasCoord;
    private float mBottomCanvasCoord;
    private float mRightCanvasCoord;
    private float mDensity;
    private RectF mRectF;
    private int mMax = Short.MIN_VALUE;
    @IMusicInfo.ViewType
    private int mViewType;
    private double[] mAudioBuffer;

    public WaveFormView(Context context) {
        super(context);
        init();
    }

    public WaveFormView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public WaveFormView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mDensity = getResources().getDisplayMetrics().density;
        mStrokeWidthPx = (int) (mDensity * STROKE_WIDTH_DP);
        mStrokePaint = new Paint();
        mStrokePaint.setColor(Color.BLACK);
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mStrokePaint.setStrokeWidth(mStrokeWidthPx);
        mStrokePaint.setStrokeCap(Paint.Cap.ROUND);
        mWaveFormPaint = new Paint();
        mWaveFormPaint.setStyle(Paint.Style.STROKE);
        mFillPaint = new Paint();
        mFillPaint.setColor(ContextCompat.getColor(getContext(), R.color.toolbar));
        mFillPaint.setStyle(Paint.Style.FILL);
        mRectF = new RectF();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();
        mLeftCanvasCoord = PADDING_DP * mDensity;
        mTopCanvasCoord = 0;
        mRightCanvasCoord = width - PADDING_DP * mDensity;
        mBottomCanvasCoord = height - PADDING_DP * mDensity;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mRectF.set(mLeftCanvasCoord, mTopCanvasCoord, mRightCanvasCoord, mBottomCanvasCoord);
        canvas.drawRect(mRectF, mFillPaint);
        float halfStrokeWidth = mStrokeWidthPx / 2f;
        mRectF.set(mLeftCanvasCoord + halfStrokeWidth, mTopCanvasCoord + halfStrokeWidth, mRightCanvasCoord - halfStrokeWidth, mBottomCanvasCoord - halfStrokeWidth);
        canvas.drawRect(mRectF, mStrokePaint);
        if (mAudioBuffer != null) {
            float[] points = new float[mViewType == IMusicInfo.ViewType.WAVEFORM
                    ? mAudioBuffer.length * 2<commit_msg>fixed point width for WaveForm in WaveFormView<commit_after>package me.foxaice.smartlight.fragments.modes.music_mode.waveformview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

import me.foxaice.smartlight.R;
import me.foxaice.smartlight.fragments.modes.music_mode.model.IMusicInfo;

public class WaveFormView extends AppCompatImageView {
    private static final int STROKE_WIDTH_DP = 2;
    private static final int PADDING_DP = 16;
    private Paint mStrokePaint;
    private Paint mFillPaint;
    private Paint mWaveFormPaint;
    private int mStrokeWidthPx;
    private float mLeftCanvasCoord;
    private float mTopCanvasCoord;
    private float mBottomCanvasCoord;
    private float mRightCanvasCoord;
    private float mDensity;
    private RectF mRectF;
    private int mMax = Short.MIN_VALUE;
    @IMusicInfo.ViewType
    private int mViewType;
    private double[] mAudioBuffer;

    public WaveFormView(Context context) {
        super(context);
        init();
    }

    public WaveFormView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public WaveFormView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mDensity = getResources().getDisplayMetrics().density;
        mStrokeWidthPx = (int) (mDensity * STROKE_WIDTH_DP);
        mStrokePaint = new Paint();
        mStrokePaint.setColor(Color.BLACK);
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mStrokePaint.setStrokeWidth(mStrokeWidthPx);
        mStrokePaint.setStrokeCap(Paint.Cap.ROUND);
        mWaveFormPaint = new Paint();
        mWaveFormPaint.setStyle(Paint.Style.STROKE);
        mWaveFormPaint.setStrokeWidth(mStrokeWidthPx);
        mFillPaint = new Paint();
        mFillPaint.setColor(ContextCompat.getColor(getContext(), R.color.toolbar));
        mFillPaint.setStyle(Paint.Style.FILL);
        mRectF = new RectF();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();
        mLeftCanvasCoord = PADDING_DP * mDensity;
        mTopCanvasCoord = 0;
        mRightCanvasCoord = width - PADDING_DP * mDensity;
        mBottomCanvasCoord = height - PADDING_DP * mDensity;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mRectF.set(mLeftCanvasCoord, mTopCanvasCoord, mRightCanvasCoord, mBottomCanvasCoord);
        canvas.drawRect(mRectF, mFillPaint);
        float halfStrokeWidth = mStrokeWidthPx / 2f;
        mRectF.set(mLeftCanvasCoord + halfStrokeWidth, mTopCanvasCoord + halfStrokeWidth, mRightCanvasCoord - halfStrokeWidth, mBottomCanvasCoord - halfStrokeWidth);
        canvas.drawRect(mRectF, mStrokePaint);
        if (mAudioBuffer != null) {
            float[] points = new float[mViewType == IMusicInfo.ViewType.WAVEFORM
                    ? mAudioBuffer.length * 2
{'fraction_non_alphanumeric': 0.08699578567128236, 'fraction_numerical': 0.002408187838651415, 'mean_word_length': 3.3919365499008594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '835784', 'n_tokens_mistral': 2044, 'n_tokens_neox': 1986, 'n_words': 420}