<commit_before>package teammemes.tritonbudget;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import teammemes.tritonbudget.Menus.Menu;
import teammemes.tritonbudget.db.MenuDataSource;

import static android.view.Gravity.CENTER;


public class PurchaseMenu extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,Serializable{

    SimpleDateFormat dateFormat;
    LinearLayout.LayoutParams layoutParams, textParams, btnParams, noWeight;
    LinearLayout mainLayout;
    FloatingActionButton myFab;
    private DrawerLayout mDrawerLayout;
    private ActionBarDrawerToggle mToggle;
    private Toolbar mToolbar;
    private User usr;
    private MenuDataSource database;
    private int[] numberOfPurchase;
    private List<Menu> transactions;
    private int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.drawer_purchase_menu);

        //Gets the user object
        usr = User.getInstance(getApplicationContext());

        //Creates the toolbar to the one defined in nav_action
        mToolbar = (Toolbar) findViewById(R.id.nav_action);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Purchase Menu");


        //Create the Drawer layout and the toggle
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_purchase_menu_layout);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);
        mDrawerLayout.addDrawerListener(mToggle);
        mToggle.syncState();


        //Create the navigationView and add a listener to listen for menu selections
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        //Get the navigation drawer header and set's the name to user's name
        View navHeaderView= navigationView.getHeaderView(0);
        TextView usrName = (TextView) navHeaderView.findViewById(R.id.header_name);
        usrName.setText(usr.getName());

        //The two sets of layout parameters that are used to make the transactions
        layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        noWeight = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        btnParams = new LinearLayout.LayoutParams(90, 100, 0);


        //Fetches the main empty layout
        mainLayout = (LinearLayout) findViewById(R.id.page);

        //Used for when database is working
        database = new MenuDataSource(this);
        transactions = database.getMenusByLocation(getIntent().getExtras().getString("FROM"));
        numberOfPurchase = new int[transactions.size()];
        dateFormat = new SimpleDateFormat("MM/dd/yyyy");
        myFab = (FloatingActionButton) findViewById(R.id.myFAB);
        myFab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ArrayList<String> trans=new ArrayList<String>();
                ArrayList<String> numofpur = new ArrayList<String>();
                for(int j=0;j<transactions.size();j++)
                {
                    if(numberOfPurchase[j]!=0)
                    {
                        Menu men = transactions.get(j);
                        //trans.add(new TranHistory(men.getId(),men.getName(),numberOfPurchase[j],new Date(),men.getCost()));
                        trans.add(""+men.getId());
                        numofpur.add(numberOfPurchase[j]+"");
                    }
                }
                if(trans.size()==0)
                {
                    Toast.makeText(getApplicationContext(),"Please select item",Toast.LENGTH_LONG).show();
                }
                else {
                    Intent checkout = new Intent(getApplicationContext(), Checkout.class);
                    checkout.putStringArrayListExtra("Transactions", trans);
                    checkout.putStringArrayListExtra("number", numofpur);
                    startActivity(checkout);
                }
            }<commit_msg>1) Fixed PurchaseMenu.java's floating action button problem.<commit_after>package teammemes.tritonbudget;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import teammemes.tritonbudget.Menus.Menu;
import teammemes.tritonbudget.db.MenuDataSource;

import static android.view.Gravity.CENTER;


public class PurchaseMenu extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,Serializable{

    SimpleDateFormat dateFormat;
    LinearLayout.LayoutParams layoutParams, textParams, btnParams, noWeight;
    LinearLayout mainLayout;
    FloatingActionButton myFab;
    private DrawerLayout mDrawerLayout;
    private ActionBarDrawerToggle mToggle;
    private Toolbar mToolbar;
    private User usr;
    private MenuDataSource database;
    private int[] numberOfPurchase;
    private List<Menu> transactions;
    private int i=0;

    private float dX;
    private float dY;
    private int lastAction;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.drawer_purchase_menu);

        //Gets the user object
        usr = User.getInstance(getApplicationContext());

        //Creates the toolbar to the one defined in nav_action
        mToolbar = (Toolbar) findViewById(R.id.nav_action);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Purchase Menu");


        //Create the Drawer layout and the toggle
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_purchase_menu_layout);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);
        mDrawerLayout.addDrawerListener(mToggle);
        mToggle.syncState();


        //Create the navigationView and add a listener to listen for menu selections
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        //Get the navigation drawer header and set's the name to user's name
        View navHeaderView= navigationView.getHeaderView(0);
        TextView usrName = (TextView) navHeaderView.findViewById(R.id.header_name);
        usrName.setText(usr.getName());

        //The two sets of layout parameters that are used to make the transactions
        layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        noWeight = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        btnParams = new LinearLayout.LayoutParams(90, 100, 0);


        //Fetches the main empty layout
        mainLayout = (LinearLayout) findViewById(R.id.page);

        //Used for when database is working
        database = new MenuDataSource(this);
        transactions = database.getMenusByLocation(getIntent().getExtras().getString("FROM"));
        numberOfPurchase = new int[transactions.size()];
        dateFormat = new SimpleDateFormat("MM/dd/yyyy");

        myFab = (FloatingActionButton) findViewById(R.id.myFAB);

        myFab.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                switch (event.getActionMasked()) {
                    case MotionEvent.ACTION_DOWN:
                        dX = view.getX() - event.getRawX();
                        dY = view.getY() - event.getRawY();
                        lastAction = MotionEvent.ACTION_DOWN;
                        break;

                    case MotionEvent.ACTION_MOVE:
                        view.setY(event.getRawY() + dY);
                        view.setX(event.getRawX() + dX);
                        lastAction = MotionEvent.ACTION_MOVE;
                        break;

                    case MotionEvent.ACTION_UP:
                        if (lastAction == MotionEvent.ACTION_DOWN) {
                            ArrayList<String> trans = new ArrayList<String>();
                            ArrayList<String> numofpur = new ArrayList<String>();
                            for (int j = 0; j < transactions.size(); j++) {
                                if (numberOfPurchase[j] != 0) {
                                    Menu men = transactions.get(j);
                                    //trans.add(new TranHistory(men.getId(),men.getName(),numberOfPurchase[j],new Date(),men.getCost()));
                                    trans.add("" + men.getId());
                                    numofpur.add(numberOfPurchase[j] + "");
                                }
                            }
                            if (trans.size() == 0) {
                                Toast.makeText(getApplicationContext(), "Please select item", Toast.LENGTH_LONG).show();
                            } else {
                                Intent checkout = new Intent(getApplicationContext(), Checkout.class);
                                checkout.putStringArrayListExtra("Transactions", trans);
                                checkout.putStringArrayListExtra("number", numofpur);
                                startActivity(checkout);
                            }
                        }
                        break;

                    default:
                        return false;
                }
                return true;
            }
{'fraction_non_alphanumeric': 0.08981513777467737, 'fraction_numerical': 0.003226369026857342, 'mean_word_length': 2.568450528935905, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2766030', 'n_tokens_mistral': 3071, 'n_tokens_neox': 2898, 'n_words': 618}