<commit_before>package com.nordicsemi.nrfUARTv2;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.util.Log;

public class Hooks {

    private final static String ACQUIRE = "R";
    @SuppressLint("StaticFieldLeak")
    private static MainActivity activity;
    private static Runnable onDisconnect;
    private static Rice onReceived;
    private static Pro onProgress;
    private static final boolean test = false;
    private static StringBuilder result = null;
    private static final int NUM_PACKETS = 58;
    private static int received = 0;

    public static void received(String text) {
        if (text.startsWith("[")) {
            if (result != null)
                Log.e("WASTED", result.toString());
            result = new StringBuilder();
            result.append(text);
            received = 0;
        } else if (text.endsWith("]")) {
            result.append(text);
            complete(result.toString());
        } else {
            result.append(text);
        }
        received++;
        onProgress.gresso(received, NUM_PACKETS);
    }

    public static void complete(String text) {
        Log.i("TAG", "received " + text);
        if (text.contains("[") && text.contains("]")) {
            String[] t = text.substring(text.indexOf('[') + 1, text.indexOf(']')).split(" ");
            float[] brusciutto = new float[512];
            if (t.length < 512) {
                for (int i = 0; i < t.length; i++) {
                    brusciutto[i] = Integer.parseInt(t[i].toUpperCase(), 16);
                }

                if (onReceived != null) {
                    onReceived.vuto(text, brusciutto, t.length);
                }
            } else
                Log.w("TAG", "Merda!!");
        } else
            Log.i("TAG", "Merda!");<commit_msg>Works with the new protocol<commit_after>package com.nordicsemi.nrfUARTv2;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.util.Log;

public class Hooks {

    private final static String ACQUIRE = "R";
    @SuppressLint("StaticFieldLeak")
    private static MainActivity activity;
    private static Runnable onDisconnect;
    private static Rice onReceived;
    private static Pro onProgress;
    private static final boolean test = false;
    private static StringBuilder result = null;
    private static final int NUM_PACKETS = 58;
    private static int received = 0;

    public static void received(String text) {
        if (text.startsWith("[")) {
            if (result != null)
                Log.e("WASTED", result.toString());
            result = new StringBuilder();
            result.append(text);
            received = 0;
        } else if (text.endsWith("]")) {
            result.append(text);
            complete(result.toString());
        } else {
            result.append(text);
        }
        received++;
        onProgress.gresso(received, NUM_PACKETS);
    }

    public static void complete(String text) {
        Log.i("TAG", "received " + text);
        if (text.contains("[") && text.contains("]")) {
            String[] t = text.substring(text.indexOf('[') + 3, text.indexOf(']')).split(" ");
            float[] brusciutto = new float[512];
            if (t.length < 512) {
                for (int i = 0; i < t.length; i++) {
                    brusciutto[i] = Integer.parseInt(t[i].toUpperCase(), 16);
                }

                if (onReceived != null) {
                    onReceived.vuto(text, brusciutto, t.length);
                }
            } else
                Log.w("TAG", "Merda!!");
        } else
            Log.i("TAG", "Merda!");
{'fraction_non_alphanumeric': 0.128680479825518, 'fraction_numerical': 0.008178844056706653, 'mean_word_length': 2.004914004914005, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1366402', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1014, 'n_words': 261}