<commit_before>package com.example.balinator.androidprojekt.widget;

import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;

import com.example.balinator.androidprojekt.R;
import com.example.balinator.androidprojekt.database.Database;
import com.example.balinator.androidprojekt.services.struct.MyService;

import java.util.ArrayList;


/**
 * Created by czimbortibor on 08/12/16.
 */

public class StatisticsWidgetViewFactory implements RemoteViewsService.RemoteViewsFactory {

    private final String tag = "ViewFactory";
    private ArrayList<MyService> mData;
    private Context context;
    private int widgetID;

    private Database db;


    public StatisticsWidgetViewFactory(Context context, Intent intent) {
        Log.v(tag, "constructor");
        this.context = context;
        this.widgetID = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        db = new Database(context);
        if (mData == null) {
            db.open();
            mData = db.getAllFavoriteService();
            db.close();
        }
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onDataSetChanged() {
        db.open();
        mData = db.getAllFavoriteService();
        db.close();
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public RemoteViews getViewAt(int i) {
        RemoteViews row = new RemoteViews(context.getPackageName(), R.layout.statistics_row);
        MyService d = data.get(i);
        row.setTextViewText(R.id.widget_statistics_row_title, d.getName());

        d.setStatistic();

        row.setTextViewText(R.id.widget_statistics_row_text_view, d.getStatistic());
        return row;
    }

    @Override
    public RemoteViews getLoadingView() {
        return null;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public long getItemId(int i) {
        return mData.get(i).getId();
    }

    @Override
    public boolean hasStableIds() {
        return true;<commit_msg>Bugfix<commit_after>package com.example.balinator.androidprojekt.widget;

import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;

import com.example.balinator.androidprojekt.R;
import com.example.balinator.androidprojekt.database.Database;
import com.example.balinator.androidprojekt.services.struct.MyService;

import java.util.ArrayList;


/**
 * Created by czimbortibor on 08/12/16.
 */

public class StatisticsWidgetViewFactory implements RemoteViewsService.RemoteViewsFactory {

    private final String tag = "ViewFactory";
    private ArrayList<MyService> mData;
    private Context context;
    private int widgetID;

    private Database db;


    public StatisticsWidgetViewFactory(Context context, Intent intent) {
        Log.v(tag, "constructor");
        this.context = context;
        this.widgetID = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        db = new Database(context);
        if (mData == null) {
            db.open();
            mData = db.getAllFavoriteService();
            db.close();
        }
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onDataSetChanged() {
        db.open();
        mData = db.getAllFavoriteService();
        db.close();
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public RemoteViews getViewAt(int i) {
        RemoteViews row = new RemoteViews(context.getPackageName(), R.layout.statistics_row);
        MyService d = mData.get(i);
        row.setTextViewText(R.id.widget_statistics_row_title, d.getName());

        d.setStatistic();

        row.setTextViewText(R.id.widget_statistics_row_text_view, d.getStatistic());
        return row;
    }

    @Override
    public RemoteViews getLoadingView() {
        return null;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public long getItemId(int i) {
        return mData.get(i).getId();
    }

    @Override
    public boolean hasStableIds() {
        return true;
{'fraction_non_alphanumeric': 0.09860383944153578, 'fraction_numerical': 0.0030541012216404886, 'mean_word_length': 2.8757396449704142, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5330384', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1319, 'n_words': 275}