<commit_before>package com.petgoldfish.wolbruv;

import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.Collections;
import java.util.List;

public class RVAdapter extends RecyclerView.Adapter<RVAdapter.MyViewHolder> {

    private LayoutInflater layoutInflater;
    private List<DeviceData> deviceDataList = Collections.emptyList();
    private WakeOnLan wakeOnLan;
    private EditText macPrompt;
    private EditText IPPrompt;
    private EditText aliasPrompt;
    private Context mContext;

    public RVAdapter(Context context, List<DeviceData> deviceData) {

        this.deviceDataList = deviceData;
        mContext = context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.list_item_row, parent, false);

        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        final DeviceData current = deviceDataList.get(position);
        String macText, IPText;
        macText = "MAC - " + current.MAC;
        IPText = "IP - " + current.IP;
        holder.aliasDisplay.setText(current.alias);
        holder.macDisplay.setText(macText);
        holder.IPDisplay.setText(IPText);
        holder.wakeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                wakeOnLan = new WakeOnLan(current.MAC, current.IP);
                new WOL().execute();
            }
        });
        holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.macDisplay.getVisibility() == View.GONE) {
                    holder.macDisplay.setVisibility(View.VISIBLE);
                    holder.IPDisplay.setVisibility(View.VISIBLE);
                    holder.editBtn.setVisibility(View.VISIBLE);
                } else {
                    holder.macDisplay.setVisibility(View.GONE);
                    holder.IPDisplay.setVisibility(View.GONE);
                    holder.editBtn.setVisibility(View.GONE);
                }
            }
        });
        holder.editBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LayoutInflater li = LayoutInflater.from(mContext);
                View promptsView = li.inflate(R.layout.add_prompt, null);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        mContext);
                alertDialogBuilder.setView(promptsView);

                macPrompt = (EditText) promptsView.findViewById(R.id.macPrompt);
                IPPrompt = (EditText) promptsView.findViewById(R.id.IPPrompt);
                aliasPrompt = (EditText) promptsView.findViewById(R.id.aliasPrompt);

                macPrompt.setText(current.MAC);
                IPPrompt.setText(current.IP);
                aliasPrompt.setText(current.alias);

                alertDialogBuilder
                        .setCancelable(false)
                        .setTitle("Edit")
                        .setPositiveButton("Save",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        DeviceData sav = DeviceData.findById(DeviceData.class, current.getId());
                                        sav.MAC = macPrompt.getText().toString().trim();
                                        sav.IP = IPPrompt.getText().toString().trim();
                                        sav.alias = aliasPrompt.getText().toString().trim();
                                        sav.save();

                                    }
                                })
                        .setNeutralButton("Delete",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        removeItem(current, holder.getAdapterPosition());
                                    }
                                })
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });

                // create alert dialog
                AlertDialog alertDialog = alertDialogBuilder.create();
<commit_msg>Updated save method to show latest data<commit_after>package com.petgoldfish.wolbruv;

import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.Collections;
import java.util.List;

public class RVAdapter extends RecyclerView.Adapter<RVAdapter.MyViewHolder> {

    private LayoutInflater layoutInflater;
    private List<DeviceData> deviceDataList = Collections.emptyList();
    private WakeOnLan wakeOnLan;
    private EditText macPrompt;
    private EditText IPPrompt;
    private EditText aliasPrompt;
    private Context mContext;

    public RVAdapter(Context context, List<DeviceData> deviceData) {

        this.deviceDataList = deviceData;
        mContext = context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.list_item_row, parent, false);

        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        final DeviceData current = deviceDataList.get(position);
        String macText, IPText;
        macText = "MAC - " + current.MAC;
        IPText = "IP - " + current.IP;
        holder.aliasDisplay.setText(current.alias);
        holder.macDisplay.setText(macText);
        holder.IPDisplay.setText(IPText);
        holder.wakeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                wakeOnLan = new WakeOnLan(current.MAC, current.IP);
                new WOL().execute();
            }
        });
        holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.macDisplay.getVisibility() == View.GONE) {
                    holder.macDisplay.setVisibility(View.VISIBLE);
                    holder.IPDisplay.setVisibility(View.VISIBLE);
                    holder.editBtn.setVisibility(View.VISIBLE);
                } else {
                    holder.macDisplay.setVisibility(View.GONE);
                    holder.IPDisplay.setVisibility(View.GONE);
                    holder.editBtn.setVisibility(View.GONE);
                }
            }
        });
        holder.editBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LayoutInflater li = LayoutInflater.from(mContext);
                View promptsView = li.inflate(R.layout.add_prompt, null);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        mContext);
                alertDialogBuilder.setView(promptsView);

                macPrompt = (EditText) promptsView.findViewById(R.id.macPrompt);
                IPPrompt = (EditText) promptsView.findViewById(R.id.IPPrompt);
                aliasPrompt = (EditText) promptsView.findViewById(R.id.aliasPrompt);

                macPrompt.setText(current.MAC);
                IPPrompt.setText(current.IP);
                aliasPrompt.setText(current.alias);

                alertDialogBuilder
                        .setCancelable(false)
                        .setTitle("Edit")
                        .setPositiveButton("Save",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        DeviceData sav = DeviceData.findById(DeviceData.class, current.getId());
                                        sav.MAC = macPrompt.getText().toString().trim();
                                        sav.IP = IPPrompt.getText().toString().trim();
                                        sav.alias = aliasPrompt.getText().toString().trim();
                                        holder.macDisplay.setText(sav.MAC);
                                        holder.IPDisplay.setText(sav.IP);
                                        holder.aliasDisplay.setText(sav.alias);
                                        sav.save();

                                    }
                                })
                        .setNeutralButton("Delete",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        removeItem(current, holder.getAdapterPosition());
                                    }
                                })
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });

                // create alert dialog
                AlertDialog alertDialog = alertDialogBuilder.create();

{'fraction_non_alphanumeric': 0.08529467143664093, 'fraction_numerical': 0.0003765769158350593, 'mean_word_length': 1.6564141035258815, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 27, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736870', 'n_tokens_mistral': 2568, 'n_tokens_neox': 2370, 'n_words': 453}