<commit_before>package de.bennir.DVBViewerController;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Vibrator;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxStatus;
import com.slidingmenu.lib.SlidingMenu;
import de.bennir.DVBViewerController.channels.DVBChannel;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URLDecoder;
import java.util.ArrayList;

public class DVBViewerControllerActivity extends SherlockFragmentActivity {
    private static final String TAG = DVBViewerControllerActivity.class.toString();
    public static String dvbHost = "";
    public static String dvbIp = "";
    public static String dvbPort = "";
    public static String recIp = "";
    public static String recPort = "";
    public static ArrayList<ArrayList<DVBChannel>> DVBChannels = new ArrayList<ArrayList<DVBChannel>>();
    public static ArrayList<String> groupNames = new ArrayList<String>();
    public static int currentGroup = -1;
    public SlidingMenu menu;
    public AQuery aq;
    public Typeface robotoThin;
    public Typeface robotoLight;
    public Typeface robotoCondensed;
    private Fragment mContent;

    @SuppressWarnings("UnusedDeclaration")
    public static void downloadChannelCallback(String url, JSONObject json, AjaxStatus ajax) {
        Log.d(TAG, "downloadChannelCallback");
        Crouton.cancelAllCroutons();

        ArrayList<DVBChannel> dvbChans = new ArrayList<DVBChannel>();

        try {
            if (json != null) {
                Log.d(TAG, "Received answer");
                JSONArray channelsJSON = new JSONArray(
                        json.getString("channels"));

                String currentGroup = "";

                for (int i = 0; i < channelsJSON.length(); i++) {
                    JSONObject chan = channelsJSON.getJSONObject(i);

                    DVBChannel dvbChannel = new DVBChannel();
                    dvbChannel.name = chan.getString("name");
                    dvbChannel.favoriteId = chan.getString("id");
                    dvbChannel.channelId = chan.getString("channelid");
                    dvbChannel.epgInfo.title = URLDecoder.decode(chan.getString("epgtitle"));
                    dvbChannel.epgInfo.time = chan.getString("epgtime");
                    dvbChannel.epgInfo.duration = chan.getString("epgduration");

                    String group = chan.getString("group");
                    if (!group.equals(currentGroup)) {
                        if (i > 0) {
                            DVBViewerControllerActivity.DVBChannels.add(dvbChans);
                            dvbChans = new ArrayList<DVBChannel>();
                        }
                        DVBViewerControllerActivity.groupNames.add(group);
                        currentGroup = group;
                    }
                    dvbChans.add(dvbChannel);
                }
                DVBViewerControllerActivity.DVBChannels.add(dvbChans);

                ChannelFragment.addChannelsToListView();
                ChannelGroupFragment.addChannelsToListView();
            }
        } catch (JSONException e) {
            e.printStackTrace();
            System.out.println(e.toString());
        }
    }

    @Override
    protected void onDestroy() {
        // Workaround until there's a way to detach the Activity from Crouton while
        // there are still some in the Queue.
        Crouton.clearCroutonsForActivity(this);<commit_msg>Fixed Crouton hiding too early<commit_after>package de.bennir.DVBViewerController;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Vibrator;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxStatus;
import com.slidingmenu.lib.SlidingMenu;
import de.bennir.DVBViewerController.channels.DVBChannel;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URLDecoder;
import java.util.ArrayList;

public class DVBViewerControllerActivity extends SherlockFragmentActivity {
    private static final String TAG = DVBViewerControllerActivity.class.toString();
    public static String dvbHost = "";
    public static String dvbIp = "";
    public static String dvbPort = "";
    public static String recIp = "";
    public static String recPort = "";
    public static ArrayList<ArrayList<DVBChannel>> DVBChannels = new ArrayList<ArrayList<DVBChannel>>();
    public static ArrayList<String> groupNames = new ArrayList<String>();
    public static int currentGroup = -1;
    public SlidingMenu menu;
    public AQuery aq;
    public Typeface robotoThin;
    public Typeface robotoLight;
    public Typeface robotoCondensed;
    private Fragment mContent;

    @SuppressWarnings("UnusedDeclaration")
    public static void downloadChannelCallback(String url, JSONObject json, AjaxStatus ajax) {
        Log.d(TAG, "downloadChannelCallback");

        ArrayList<DVBChannel> dvbChans = new ArrayList<DVBChannel>();

        try {
            if (json != null) {
                Log.d(TAG, "Received answer");
                JSONArray channelsJSON = new JSONArray(
                        json.getString("channels"));

                String currentGroup = "";

                for (int i = 0; i < channelsJSON.length(); i++) {
                    JSONObject chan = channelsJSON.getJSONObject(i);

                    DVBChannel dvbChannel = new DVBChannel();
                    dvbChannel.name = chan.getString("name");
                    dvbChannel.favoriteId = chan.getString("id");
                    dvbChannel.channelId = chan.getString("channelid");
                    dvbChannel.epgInfo.title = URLDecoder.decode(chan.getString("epgtitle"));
                    dvbChannel.epgInfo.time = chan.getString("epgtime");
                    dvbChannel.epgInfo.duration = chan.getString("epgduration");

                    String group = chan.getString("group");
                    if (!group.equals(currentGroup)) {
                        if (i > 0) {
                            DVBViewerControllerActivity.DVBChannels.add(dvbChans);
                            dvbChans = new ArrayList<DVBChannel>();
                        }
                        DVBViewerControllerActivity.groupNames.add(group);
                        currentGroup = group;
                    }
                    dvbChans.add(dvbChannel);
                }
                DVBViewerControllerActivity.DVBChannels.add(dvbChans);

                ChannelFragment.addChannelsToListView();
                ChannelGroupFragment.addChannelsToListView();


            }
        } catch (JSONException e) {
            e.printStackTrace();
            System.out.println(e.toString());
        } finally {
            Crouton.cancelAllCroutons();
        }
    }

    @Override
    protected void onDestroy() {
        // Workaround until there's a way to detach the Activity from Crouton while
        // there are still some in the Queue.
        Crouton.clearCroutonsForActivity(this);
{'fraction_non_alphanumeric': 0.09181829136040487, 'fraction_numerical': 0.0009639715628388962, 'mean_word_length': 2.5622317596566524, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4044632', 'n_tokens_mistral': 2236, 'n_tokens_neox': 2127, 'n_words': 462}