From 9bd32af508bbc62a342ec88da78f3f361dff3baa Mon Sep 17 00:00:00 2001
From: yusenw2 <yusenw2@illinois.edu>
Date: Mon, 9 Sep 2019 07:23:54 -0500
Subject: [PATCH] part3

---
 part3/.DS_Store                  | Bin 0 -> 6148 bytes
 part3/Action.java                |  56 +++
 part3/ActionListAdapter.java     | 101 +++++
 part3/App.java                   |  24 ++
 part3/GameStats.java             | 339 ++++++++++++++++
 part3/InputActivity.java         | 652 +++++++++++++++++++++++++++++++
 part3/MainActivity.java          | 212 ++++++++++
 part3/Match.java                 |  49 +++
 part3/MatchList.java             |  13 +
 part3/MyCustomAdapter.java       | 127 ++++++
 part3/Period.java                |  49 +++
 part3/RecyclerViewAdapter.java   |  90 +++++
 part3/SwipeToDeleteCallback.java | 102 +++++
 part3/Team.java                  |  64 +++
 part3/test_activity.java         |  96 +++++
 15 files changed, 1974 insertions(+)
 create mode 100644 part3/.DS_Store
 create mode 100644 part3/Action.java
 create mode 100644 part3/ActionListAdapter.java
 create mode 100644 part3/App.java
 create mode 100644 part3/GameStats.java
 create mode 100644 part3/InputActivity.java
 create mode 100644 part3/MainActivity.java
 create mode 100644 part3/Match.java
 create mode 100644 part3/MatchList.java
 create mode 100644 part3/MyCustomAdapter.java
 create mode 100644 part3/Period.java
 create mode 100644 part3/RecyclerViewAdapter.java
 create mode 100644 part3/SwipeToDeleteCallback.java
 create mode 100644 part3/Team.java
 create mode 100644 part3/test_activity.java

diff --git a/part3/.DS_Store b/part3/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..7215d5020f823e7127caa755473a897a54d6273e
GIT binary patch
literal 6148
zcmeHK%}T>S5T2<OB7*klabLhg@hrp=51#u1(nR!-l2G-Yn-AbK_#hs<`A+)H52Yna
zz=M=B12f<5X1;9lZOL?qh-c5$lxRXk8C-C5gz$sOb@85!eB}_xdXFc1q;p!)9hJT8
zSlC4c<m^syYArQ5x6SjDd4-c)-PBFFsG9{c@iXBQ;LDeqzR&=>zMsy^X4z`4g#pI0
zDGJ{&d%O7fynKDX0&$R4{ejg!^qy|xL1P#SgaV<!o+^NvEtVY{Mhpc)fly$rfP5bk
zTrhX+4E582pe+D!jAb>9rI!#+a?Bk&LtKHeQGrHfZ!y^DSWljpJ9dUfC-&xpeP{L#
zg>`q_KWRE~ZWu8X2nDtkII!tN>i_lc{r@&8W}!eRuvZH3xR@6+ypq?}-pfg?P4HW|
onB;YaYYGNhijga&_zbRw^&|se?${Y(1r~n<RE7wlz`rW+4I&~+UjP6A

literal 0
HcmV?d00001

diff --git a/part3/Action.java b/part3/Action.java
new file mode 100644
index 0000000..b050eb2
--- /dev/null
+++ b/part3/Action.java
@@ -0,0 +1,56 @@
+package com.cs498MD.SportsRecorder;
+
+enum Type {Attempt, Score, Foul;}
+
+public class Action {
+    private String teamName;
+    Type type;
+    Integer point;
+    String message;
+
+    public Type getType() {
+        return type;
+    }
+
+    public Action(String teamName, Type type, Integer point) {
+        this.teamName = teamName;
+        this.type = type;
+        this.point = point;
+
+        if (type == Type.Attempt) {
+            this.message = teamName + " missed!";
+        } else if (type == Type.Score) {
+            this.message = teamName + " got " + point + " point" + (point == 1 ? "!" : "s!");
+        } else {
+            this.message = teamName + " made a foul!";
+        }
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    public String getTeamName() {
+        return teamName;
+    }
+
+    public void setTeamName(String teamName) {
+        this.teamName = teamName;
+    }
+
+    public int getPoint() {
+        return point;
+    }
+
+    public void setPoint(int point) {
+        this.point = point;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}
diff --git a/part3/ActionListAdapter.java b/part3/ActionListAdapter.java
new file mode 100644
index 0000000..7f0166d
--- /dev/null
+++ b/part3/ActionListAdapter.java
@@ -0,0 +1,101 @@
+package com.cs498MD.SportsRecorder;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.TextView;
+
+
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+
+import static android.content.Context.MODE_PRIVATE;
+
+public class ActionListAdapter extends BaseAdapter {
+    private ArrayList<String> list;
+    private ArrayList<String> matchIdList;
+    private Context context;
+    private Activity activity;
+
+    private String MATCH = "match";
+
+    public ActionListAdapter(ArrayList<String> list, ArrayList<String> matchIdList, Context context, Activity activity) {
+        this.list = list;
+        this.context = context;
+        this.activity = activity;
+        this.matchIdList = matchIdList;
+    }
+
+    public ActionListAdapter(ArrayList<String> list,  Context context, Activity activity) {
+        this.list = list;
+        this.context = context;
+        this.activity = activity;
+
+    }
+
+    @Override
+    public int getCount() {
+        return list.size();
+    }
+
+    @Override
+    public Object getItem(int pos) {
+        return list.get(pos);
+    }
+
+    @Override
+    public long getItemId(int pos) {
+        return 0;
+        //just return 0 if your list items do not have an Id variable.
+    }
+
+    public String getMatchId(int pos) {
+        return matchIdList.get(pos);
+    }
+
+    public void clear() {
+        list.clear();
+    }
+
+    @Override
+    public View getView(final int position, View convertView, final ViewGroup parent) {
+        View view = convertView;
+        if (view == null) {
+            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            view = inflater.inflate(R.layout.action_list_layout, null);
+        }
+
+        //Handle TextView and display string from your list
+        final TextView listItemText = (TextView)view.findViewById(R.id.action_item_string);
+        listItemText.setText(list.get(position));
+
+        //Handle buttons and add onClickListeners
+        Button delete_btn = (Button)view.findViewById(R.id.action_delete_btn);
+
+        delete_btn.setOnClickListener(new View.OnClickListener(){
+            @Override
+            public void onClick(View v) {
+                //do something
+                list.remove(position); //delete action
+                notifyDataSetChanged();
+
+
+
+            }
+        });
+        return view;
+    }
+
+
+}
\ No newline at end of file
diff --git a/part3/App.java b/part3/App.java
new file mode 100644
index 0000000..5def85a
--- /dev/null
+++ b/part3/App.java
@@ -0,0 +1,24 @@
+package com.cs498MD.SportsRecorder;
+
+import android.app.Application;
+import android.graphics.Typeface;
+
+/**
+ * Copied from github
+ * For original author, go to: https://github.com/Yalantis/GuillotineMenu-Android
+ */
+public class App extends Application {
+    private static final String CANARO_EXTRA_BOLD_PATH = "fonts/canaro_extra_bold.otf";
+    public static Typeface canaroExtraBold;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        initTypeface();
+    }
+
+    private void initTypeface() {
+        canaroExtraBold = Typeface.createFromAsset(getAssets(), CANARO_EXTRA_BOLD_PATH);
+
+    }
+}
diff --git a/part3/GameStats.java b/part3/GameStats.java
new file mode 100644
index 0000000..157f608
--- /dev/null
+++ b/part3/GameStats.java
@@ -0,0 +1,339 @@
+package com.cs498MD.SportsRecorder;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.graphics.Typeface;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+
+import com.google.gson.Gson;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class GameStats extends AppCompatActivity implements View.OnClickListener {
+
+    private static final Integer SCORE_TABLE = 0;
+    private static final Integer TEAM_TABLE = 1;
+    private static final Integer PLAYER_TABLE = 2;
+
+    private Integer[] teamPeriodScores = {0, 0, 0, 0, 0, 0}; // 0th Period is the Total Game Score
+    private Integer[] oppPeriodScores = {0, 0, 0, 0, 0, 0};
+    private Integer[] gameBreakDown = {0, 0, 0, 0, 0};
+    private Integer[] myKidBreakDown = {0, 0, 0, 0, 0};
+    private Integer[] othersBreakDown = {0, 0, 0, 0, 0};
+
+    private String myKidName;
+
+    private static TextView scores;
+    private String matchJson;
+    private Match match;
+    private String matchName;
+
+    private TableLayout scoreTable;
+    private TableLayout teamTable;
+    private TableLayout playerTable;
+
+    private static String[] SCORE_HEADER = {"Team", "Total", "QTR 1", "QTR 2", "QTR 3", "QTR 4", "QTR 4+"};
+    private static String[] TEAM_HEADER = {"Total", "1 PT", "2 PT", "3 PT", "Foul"};
+    private static String[] PLAYER_HEADER = {"Player", "Total", "1 PT", "2 PT", "3 PT", "Foul"};
+
+    private void formatHeaderText(TextView tv, String text) {
+        tv.setText(text);
+        tv.setPadding(32, 0, 32, 0);
+        tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
+        tv.setTextSize(20);
+        tv.setTypeface(null, Typeface.BOLD);
+        tv.setBackgroundResource(R.drawable.cell_shape);
+    }
+
+    private void formatTableText(TextView tv) {
+        tv.setBackgroundResource(R.drawable.cell_shape);
+        tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
+        tv.setPadding(32, 0, 32, 0);
+        tv.setTextSize(20);
+    }
+
+    private void createHeaderRow(Integer table) {
+        switch (table) {
+            case 0:
+                TableRow scoreHeader = new TableRow(GameStats.this);
+
+                // Set header for score breakdown table
+                for (int i = 0; i < SCORE_HEADER.length; i++) {
+                    TextView tv = new TextView(GameStats.this);
+                    formatHeaderText(tv, SCORE_HEADER[i]);
+
+                    if (i < SCORE_HEADER.length) { tv.setBackgroundResource(R.drawable.cell_shape); }
+                    scoreHeader.addView(tv);
+                }
+                scoreTable.addView(scoreHeader);
+                break;
+            case 1:
+                TableRow teamHeader = new TableRow(GameStats.this);
+
+                for (int i = 0; i < TEAM_HEADER.length; i++) {
+                    TextView tv = new TextView(GameStats.this);
+                    formatHeaderText(tv, TEAM_HEADER[i]);
+
+                    if (i < TEAM_HEADER.length) { tv.setBackgroundResource(R.drawable.cell_shape); }
+                    teamHeader.addView(tv);
+                }
+
+                teamTable.addView(teamHeader);
+                break;
+            case 2:
+                TableRow playerHeader = new TableRow(GameStats.this);
+
+                for (int i = 0; i < PLAYER_HEADER.length; i++) {
+                    TextView tv = new TextView(GameStats.this);
+                    formatHeaderText(tv, PLAYER_HEADER[i]);
+
+                    if (i < PLAYER_HEADER.length) { tv.setBackgroundResource(R.drawable.cell_shape); }
+                    playerHeader.addView(tv);
+                }
+                playerTable.addView(playerHeader);
+                break;
+        }
+    }
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+//        MenuInflater inflater = getMenuInflater();
+//        inflater.inflate(R.menu.stats_menu, menu);
+        return true;
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_game_stats);
+
+//        findViewById(R.id.send).setOnClickListener(this);
+
+        scores = findViewById(R.id.score);
+        scores.setBackgroundResource(R.drawable.border_bottom);
+
+        scoreTable = findViewById(R.id.overallStats);
+        teamTable = findViewById(R.id.teamStats);
+        playerTable = findViewById(R.id.playerStats);
+
+        String matchId = getIntent().getStringExtra("matchId");
+        SharedPreferences sharedPreferences = getSharedPreferences("match", MODE_PRIVATE);
+
+        matchJson = sharedPreferences.getString(matchId, "");
+
+        Gson gson = new Gson();
+        match = gson.fromJson(matchJson, Match.class);
+
+        matchName = match.getName();
+
+        ActionBar actionBar = getSupportActionBar();
+        actionBar.setDisplayShowHomeEnabled(true);
+
+        actionBar.setTitle(matchName);
+
+        int periodCount = 1;
+
+        Period[] periods = match.getPeriods();
+        for (int i = 0; i < periods.length; i++){
+            Period period = periods[i];
+
+            Team oppTeam = period.getOpponent();
+            oppPeriodScores[0] += oppTeam.getScore();
+            oppPeriodScores[periodCount] += (oppTeam.getScore());
+
+            Team myKid = period.getKid();
+            Team others = period.getOthers();
+            teamPeriodScores[0] += myKid.getScore() + others.getScore();
+            teamPeriodScores[periodCount++] += myKid.getScore() + others.getScore();
+
+            // PLAYER STUFF!!
+            myKidBreakDown[0] += myKid.getScore();
+            myKidBreakDown[1] += myKid.getOnePoint();
+            myKidBreakDown[2] += myKid.getTwoPoint();
+            myKidBreakDown[3] += myKid.getThreePoint();
+            myKidBreakDown[4] += myKid.getMiss();
+
+            othersBreakDown[0] += others.getScore();
+            othersBreakDown[1] += others.getOnePoint();
+            othersBreakDown[2] += others.getTwoPoint();
+            othersBreakDown[3] += others.getThreePoint();
+            othersBreakDown[4] += others.getMiss();
+
+            myKidName = myKid.getName();
+
+            if (periodCount > 5) {
+                periodCount = 5;
+            }
+
+            gameBreakDown[0] += myKid.getScore() + others.getScore();
+            gameBreakDown[1] += myKid.getOnePoint() + others.getOnePoint();
+            gameBreakDown[2] += myKid.getTwoPoint() + others.getTwoPoint();
+            gameBreakDown[3] += myKid.getThreePoint() + others.getThreePoint();
+            gameBreakDown[4] += myKid.getMiss() + others.getMiss();
+        }
+
+        Log.d("TEAM DEBUG", match.getName());
+
+        populateScoreTable();
+//        populateTeamTable();
+        populatePlayerTable();
+
+        // Hiding Text for Team Table
+//        ((TextView) findViewById(R.id.teamStatsTitle)).setText("");
+    }
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        if (item.getItemId() == R.id.stats_menu_id) {
+            Log.e("TEST", "clicked");
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    public void onClick(View v) {
+//        if (v.getId() == R.id.send) {
+//            Intent sendIntent = new Intent();
+//            sendIntent.setAction(Intent.ACTION_SEND);
+//            sendIntent.putExtra(Intent.EXTRA_TEXT, matchJson);
+//            sendIntent.setType("text/plain");
+//
+//            if (sendIntent.resolveActivity(getPackageManager()) != null) {
+//                startActivity(sendIntent);
+//            }
+//        }
+    }
+
+    private void populateScoreTable() {
+        // Create Header Row
+        createHeaderRow(SCORE_TABLE);
+
+        // TODO: Extract Team names from Shared Preferences
+        String[] teams = {"My Team", "Opponent"};
+
+        for (int i = 0; i < teams.length; i++) {
+            TableRow row = new TableRow(GameStats.this);
+
+            TextView tv = new TextView(GameStats.this);
+            formatTableText(tv);
+            tv.setTextColor(i==0 ? 0xFFC0392B:0xFF2980B9);
+            tv.setText(teams[i]);
+            row.addView(tv);
+
+            for (int j = 0; j < teamPeriodScores.length; j++) {
+                tv = new TextView(GameStats.this);
+                formatTableText(tv);
+                tv.setText(i == 0 ? teamPeriodScores[j].toString() : oppPeriodScores[j].toString());
+                row.addView(tv);
+            }
+
+            scoreTable.addView(row);
+        }
+    }
+
+    private void populateTeamTable() {
+        createHeaderRow(TEAM_TABLE);
+
+        TableRow row = new TableRow(GameStats.this);
+        for (int i = 0; i < TEAM_HEADER.length; i++) {
+            TextView tv = new TextView(GameStats.this);
+            formatTableText(tv);
+            tv.setText(gameBreakDown[i].toString());
+            row.addView(tv);
+        }
+
+        teamTable.addView(row);
+    }
+
+    private void populatePlayerTable() {
+        // Only create Players Table if there are players to keep track of
+        String[] players = {myKidName, "Others", "Overall"};
+
+        createHeaderRow(PLAYER_TABLE);
+
+        TableRow kidRow = new TableRow(GameStats.this);
+        TableRow otherRow = new TableRow(GameStats.this);
+        TableRow overallRow = new TableRow(GameStats.this);
+
+        for (int i = 0; i < players.length; i++) {
+            TextView tv = new TextView(GameStats.this);
+            formatTableText(tv);
+            switch (i) {
+                case 0:
+                    tv.setText(players[i]);
+                    kidRow.addView(tv);
+                    break;
+                case 1:
+                    tv.setText(players[i]);
+                    otherRow.addView(tv);
+                    break;
+                case 2:
+                    tv.setText(players[i]);
+                    overallRow.addView(tv);
+                    break;
+            }
+        }
+
+        for (int i = 0; i < PLAYER_HEADER.length - 1; i++) {
+            TextView kid = new TextView(GameStats.this);
+            TextView other = new TextView(GameStats.this);
+            TextView overall = new TextView(GameStats.this);
+
+            formatTableText(kid);
+            formatTableText(other);
+            formatTableText(overall);
+
+            int kidScore = myKidBreakDown[i];
+            int otherScore = othersBreakDown[i];
+
+            kid.setText(Integer.toString(kidScore));
+            other.setText(Integer.toString(otherScore));
+            overall.setText(Integer.toString(kidScore + otherScore));
+
+            kidRow.addView(kid);
+            otherRow.addView(other);
+            overallRow.addView(overall);
+        }
+
+        playerTable.addView(kidRow);
+        playerTable.addView(otherRow);
+        playerTable.addView(overallRow);
+
+//        for (String player : players) {
+//            TableRow row = new TableRow(GameStats.this);
+
+//            TextView tv = new TextView(GameStats.this);
+//            formatTableText(tv);
+//            tv.setText(player);
+//            row.addView(tv);
+//
+//            for (int i = 0; i < PLAYER_HEADER.length - 1; i++) {
+//                tv = new TextView(GameStats.this);
+//                formatTableText(tv);
+//                tv.setText(player.equals("Others") ? othersBreakDown[i].toString() : myKidBreakDown[i].toString());
+//                row.addView(tv);
+//            }
+//
+//            playerTable.addView(row);
+//        }
+    }
+
+    @Override
+    public void onBackPressed() {
+        super.onBackPressed();
+        if (match.isDone()) {
+            startActivity(new Intent(this, MainActivity.class));
+        }
+    }
+}
\ No newline at end of file
diff --git a/part3/InputActivity.java b/part3/InputActivity.java
new file mode 100644
index 0000000..10dff13
--- /dev/null
+++ b/part3/InputActivity.java
@@ -0,0 +1,652 @@
+package com.cs498MD.SportsRecorder;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+import android.view.animation.AccelerateInterpolator;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
+import com.google.android.material.snackbar.Snackbar;
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+
+import androidx.annotation.NonNull;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.recyclerview.widget.ItemTouchHelper;
+import androidx.recyclerview.widget.RecyclerView;
+
+public class InputActivity extends Activity implements View.OnClickListener {
+
+    // Match Utils
+    private String matchId;
+    private Period period;
+    private final String MATCH = "match";
+    private TextView lastAction;
+    private TextView tutorial;
+    private TextView matchName;
+    private TextView myKid;
+
+    // Teams
+    private int kidOne;
+    private int kidTwo;
+    private int kidThree;
+    private int kidMiss;
+
+    // Period
+    private int currPeriod;
+
+    private TextView myScoreView;
+    private TextView opponentScoreView;
+
+    // Active match info
+    private Match match;
+    private int kidScore;
+    private int othersScore;
+    private int oppScore;
+    private int prevKidScore;
+    private int prevOthersScore;
+    private int prevOppScore;
+
+    private Stack<Action> history;
+
+    //bottom sheet
+    private BottomSheetBehavior bottomSheetBehavior;
+    private LinearLayout linearLayoutBSheet;
+    private ToggleButton tbUpDown;
+
+    public ArrayList<String> actions = new ArrayList<>();
+    private ArrayList<String> actionID = new ArrayList<>();
+    private ActionListAdapter adapter;
+
+
+    RecyclerView recyclerView;
+    RecyclerViewAdapter mAdapter;
+
+    ArrayList<String> stringArrayList = new ArrayList<>();
+    CoordinatorLayout coordinatorLayout;
+
+
+    List<Button> actionButtons = new ArrayList<>();
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_input_page);
+
+        initViews();
+        initMatchInfo();
+
+        init_bottomsheet();
+
+
+        tbUpDown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if(isChecked){
+                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
+
+                }else{
+                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
+
+                }
+            }
+        });
+
+        bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
+            @Override
+            public void onStateChanged(View view, int newState) {
+                if(newState == BottomSheetBehavior.STATE_EXPANDED){
+                    tbUpDown.setChecked(true);
+                    lastAction.setText("Game History");
+                    tutorial.setText("(Swipe Left To Delete)");
+
+                }else if(newState == BottomSheetBehavior.STATE_COLLAPSED){
+                    tbUpDown.setChecked(false);
+                    if(!period.getHistory().empty()){
+                        lastAction.setText(period.getHistory().peek().message);
+                        tutorial.setText("");
+                    }
+                    else{
+                        lastAction.setText("Slide to view game history");
+                        tutorial.setText("");
+                    }
+
+                }
+            }
+
+            @Override
+            public void onSlide(View view, float v) {
+
+            }
+        });
+
+//        adapter = new ActionListAdapter(actions,this, InputActivity.this);
+
+//        ListView listView = (ListView) findViewById(R.id.matchList);
+//        listView.setEmptyView(findViewById(R.id.noActions));
+//        listView.setAdapter(adapter);
+
+        recyclerView = findViewById(R.id.recyclerView);
+        coordinatorLayout = findViewById(R.id.coordinatorLayout);
+
+//        populateRecyclerView();
+        enableSwipeToDeleteAndUndo();
+
+    }
+
+
+
+    /* ================================================================================================================================================= */
+    /* ================================================================ Initialization ================================================================= */
+    /* ================================================================================================================================================= */
+
+    private void initViews() {
+        // Game Util Views
+        lastAction = findViewById(R.id.txtCantante);
+        tutorial = findViewById(R.id.tutorial);
+//        findViewById(R.id.undo).setOnClickListener(this);
+        findViewById(R.id.end_game).setOnClickListener(this);
+        findViewById(R.id.view_game_stats).setOnClickListener(this);
+
+        matchName = findViewById(R.id.match_name);
+        myScoreView = findViewById(R.id.my_score);
+        opponentScoreView = findViewById(R.id.opp_score);
+        myKid = findViewById(R.id.my_kid);
+
+        // Others Views
+        findViewById(R.id.other_free_throw).setOnClickListener(this);
+        findViewById(R.id.other_two_ptr).setOnClickListener(this);
+        findViewById(R.id.other_three_ptr).setOnClickListener(this);
+        findViewById(R.id.other_miss).setOnClickListener(this);
+
+        // Kid Views
+        findViewById(R.id.myKid_free_throw).setOnClickListener(this);
+        findViewById(R.id.myKid_two_ptr).setOnClickListener(this);
+        findViewById(R.id.myKid_three_ptr).setOnClickListener(this);
+        findViewById(R.id.myKid_miss).setOnClickListener(this);
+
+        // Opponent Views
+        findViewById(R.id.opp_free_throw).setOnClickListener(this);
+        findViewById(R.id.opp_two_ptr).setOnClickListener(this);
+        findViewById(R.id.opp_three_ptr).setOnClickListener(this);
+        findViewById(R.id.opp_miss).setOnClickListener(this);
+
+        // Periods
+        findViewById(R.id.period_one).setOnClickListener(this);
+        findViewById(R.id.period_two).setOnClickListener(this);
+        findViewById(R.id.period_three).setOnClickListener(this);
+        findViewById(R.id.period_four).setOnClickListener(this);
+        findViewById(R.id.period_fourPlus).setOnClickListener(this);
+    }
+
+    private void initMatchInfo() {
+        matchId = getIntent().getStringExtra("matchId");
+        match = new Match(Integer.parseInt(matchId));
+        match.setName(getIntent().getStringExtra("matchName"));
+        matchName.setText(getIntent().getStringExtra("matchName"));
+
+
+        initPeriodInfo(0);
+
+        /* Assume we only enter inputActivity by clicking add button in mainActivity */
+
+//        SharedPreferences sharedPreferences = getSharedPreferences(MATCH, MODE_PRIVATE);
+//        Gson gson = new Gson();
+//
+//        String matchJson = sharedPreferences.getString(matchId, "");
+//
+//        if (matchJson == null || matchJson.equals("")) {
+//            match = new Match(Integer.parseInt(matchId));
+//        } else {
+//            match = gson.fromJson(matchJson, Match.class);
+//        }
+    }
+
+    private void savePeriodInfo() {
+        Team kid = period.getKid();
+        kid.setMiss(kidMiss);
+        kid.setScore(kidScore - prevKidScore);
+        kid.setOnePoint(kidOne);
+        kid.setTwoPoint(kidTwo);
+        kid.setThreePoint(kidThree);
+
+        period.getOpponent().setScore(oppScore - prevOppScore);
+        period.getOthers().setScore(othersScore - prevOthersScore);
+    }
+
+    private void initPeriodInfo(int idx) {
+        if (idx > 0) {
+            savePeriodInfo();
+        }
+
+        // SET BUTTON COLOR
+        switch (idx) {
+            case 0:
+                currPeriod = R.id.period_one;
+                break;
+            case 1:
+                currPeriod = R.id.period_two;
+                break;
+            case 2:
+                currPeriod = R.id.period_three;
+                break;
+            case 3:
+                currPeriod = R.id.period_four;
+                break;
+            case 4:
+                currPeriod = R.id.period_fourPlus;
+                break;
+        }
+
+        findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.selected_period)));
+        // END OF SET BUTTON COLOR
+
+        period = match.getPeriods()[idx];
+        period.getKid().setName(getIntent().getStringExtra("kidName"));
+        myKid.setText(getIntent().getStringExtra("kidName"));
+
+        prevOppScore = oppScore; prevKidScore = kidScore; prevOthersScore = othersScore;
+        kidOne = 0; kidTwo = 0; kidThree = 0; kidMiss = 0;
+
+        history = period.getHistory();
+        if (history.isEmpty()) {
+            lastAction.setText(getString(R.string.action_description));
+        } else {
+            lastAction.setText(history.peek().getMessage());
+        }
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v.getId() == R.id.view_game_stats) {
+            Intent intent = new Intent(this, GameStats.class);
+            intent.putExtra("matchId", matchId);
+            startActivity(intent);
+        }
+//        else if (v.getId() == R.id.undo && history.size() >= 1) {
+//            undoLastAction();
+//        }
+        else if (v.getId() == R.id.end_game) {
+            showAlertDialog(v);
+        } else if (v.getId() == R.id.period_one) {
+            findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.periods)));
+            initPeriodInfo(0);
+        } else if (v.getId() == R.id.period_two) {
+            findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.periods)));
+            initPeriodInfo(1);
+        } else if (v.getId() == R.id.period_three) {
+            findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.periods)));
+            initPeriodInfo(2);
+        } else if (v.getId() == R.id.period_four) {
+            findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.periods)));
+            initPeriodInfo(3);
+        } else if (v.getId() == R.id.period_fourPlus) {
+            findViewById(currPeriod).setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.periods)));
+            initPeriodInfo(4);
+        }
+
+        else {
+            switch (v.getId()) {
+                case R.id.opp_free_throw:
+                    oppScore += 1;
+                    setLastAction(new Action(period.getOpponent().getName(), Type.Score, 1));
+                    break;
+                case R.id.opp_two_ptr:
+                    oppScore += 2;
+                    setLastAction(new Action(period.getOpponent().getName(), Type.Score, 2));
+                    break;
+                case R.id.opp_three_ptr:
+                    oppScore += 3;
+                    setLastAction(new Action(period.getOpponent().getName(), Type.Score, 3));
+                    break;
+                case R.id.opp_miss:
+                    setLastAction(new Action(period.getOpponent().getName(), Type.Foul, 1));
+                    break;
+                case R.id.other_free_throw:
+                    othersScore += 1;
+                    setLastAction(new Action(period.getOthers().getName(), Type.Score, 1));
+                    break;
+                case R.id.other_two_ptr:
+                    othersScore += 2;
+                    setLastAction(new Action(period.getOthers().getName(), Type.Score, 2));
+                    break;
+                case R.id.other_three_ptr:
+                    othersScore += 3;
+                    setLastAction(new Action(period.getOthers().getName(), Type.Score, 3));
+                    break;
+                case R.id.other_miss:
+                    setLastAction(new Action(period.getOthers().getName(), Type.Foul, 1));
+                    break;
+                case R.id.myKid_free_throw:
+                    kidOne += 1;
+                    kidScore += 1;
+                    setLastAction(new Action(period.getKid().getName(), Type.Score, 1));
+                    break;
+                case R.id.myKid_two_ptr:
+                    kidTwo += 2;
+                    kidScore += 2;
+                    setLastAction(new Action(period.getKid().getName(), Type.Score, 2));
+                    break;
+                case R.id.myKid_three_ptr:
+                    kidThree += 3;
+                    kidScore += 3;
+                    setLastAction(new Action(period.getKid().getName(), Type.Score, 3));
+                    break;
+                case R.id.myKid_miss:
+                    kidMiss += 1;
+                    setLastAction(new Action(period.getKid().getName(), Type.Foul, 1));
+                    break;
+            }
+
+            myScoreView.setText(String.valueOf(kidScore + othersScore));
+            opponentScoreView.setText(String.valueOf(oppScore));
+        }
+
+        actions.clear();
+
+        for(Action action : period.getHistory())
+        {
+            actions.add(action.message);
+        }
+
+        Collections.reverse(actions);
+        populateRecyclerView();
+
+
+
+        //delete button on click
+//        Button deleteActionHistoryBtn = findViewById(R.id.action_delete_btn);
+//        deleteActionHistoryBtn.setOnClickListener(new View.OnClickListener() {
+//            @Override
+//            public void onClick(View v) {
+//                RecyclerView.ViewHolder viewHolder = mAdapter.onCreateViewHolder(recyclerView, 0);
+//                final int position = viewHolder.getAdapterPosition();
+//                final String item = mAdapter.getData().get(position);
+//
+//                mAdapter.removeItem(position);
+//                final Action temp_action = history.get(position);
+//                undoSpecificAction(history.get(position));
+//
+//
+//
+//
+//
+//                Snackbar snackbar = Snackbar
+//                        .make(coordinatorLayout, "Action was deleted.", Snackbar.LENGTH_LONG);
+//                snackbar.setAction("UNDO", new View.OnClickListener() {
+//                    @Override
+//                    public void onClick(View view) {
+//
+//                        mAdapter.restoreItem(item, position);
+//                        recyclerView.scrollToPosition(position);
+//                        setLastAction(temp_action);
+//                        if(temp_action.getTeamName().equals(period.getOthers().getName())){
+//                            //opponent
+//
+//                            oppScore+= temp_action.point;
+//                            opponentScoreView.setText(String.valueOf(oppScore));
+//                        }
+//                        else{
+//
+//                            kidScore += temp_action.point;
+//
+//                            myScoreView.setText(String.valueOf(kidScore + othersScore));
+//                        }
+//
+//                    }
+//                });
+//
+//                snackbar.setActionTextColor(Color.YELLOW);
+//                snackbar.show();
+//
+//            }
+//
+//
+//        });
+
+//        adapter.notifyDataSetChanged();
+    }
+
+    /* ================================================================================================================================================= */
+    /* ==================================================================== Actions ==================================================================== */
+    /* ================================================================================================================================================= */
+    private void undoLastAction() {
+        Action action = history.pop();
+        if (action.getType() == Type.Score) {
+            if (action.getTeamName().equals(period.getOthers().getName())) {
+                othersScore -= action.getPoint();
+                myScoreView.setText(String.valueOf(othersScore + kidScore));
+            } else if (action.getTeamName().equals(period.getOpponent().getName())) {
+                oppScore -= action.getPoint();
+                opponentScoreView.setText(String.valueOf(oppScore));
+            } else {
+                kidScore -= action.getPoint();
+                myScoreView.setText(String.valueOf(othersScore + kidScore));
+
+                switch (action.getPoint()) {
+                    case 1:
+                        kidOne--;
+                    case 2:
+                        kidTwo--;
+                    case 3:
+                        kidThree--;
+                }
+            }
+        } else if (action.getType() == Type.Attempt && action.getTeamName().equals(period.getKid().getName())) {
+            kidMiss--;
+        }
+        lastAction.setText(history.isEmpty() ? getString(R.string.action_description) : history.peek().getMessage());
+    }
+
+
+    private void undoSpecificAction(Action action, int position) {
+
+        history.remove(position);
+        if (action.getType() == Type.Score) {
+            if (action.getTeamName().equals(period.getOthers().getName())) {
+                othersScore -= action.getPoint();
+                myScoreView.setText(String.valueOf(othersScore + kidScore));
+            } else if (action.getTeamName().equals(period.getOpponent().getName())) {
+                oppScore -= action.getPoint();
+                opponentScoreView.setText(String.valueOf(oppScore));
+            } else {
+                kidScore -= action.getPoint();
+                myScoreView.setText(String.valueOf(othersScore + kidScore));
+
+                switch (action.getPoint()) {
+                    case 1:
+                        kidOne--;
+                    case 2:
+                        kidTwo--;
+                    case 3:
+                        kidThree--;
+                }
+            }
+        } else if (action.getType() == Type.Attempt && action.getTeamName().equals(period.getKid().getName())) {
+            kidMiss--;
+        }
+        lastAction.setText(history.isEmpty() ? getString(R.string.action_description) : history.peek().getMessage());
+    }
+
+
+
+    private void setLastAction(Action action) {
+        history.push(action);
+        lastAction.setText(action.getMessage());
+    }
+
+    /* ================================================================================================================================================= */
+    /* ================================================================== END MATCH ==================================================================== */
+    /* ================================================================================================================================================= */
+
+    private void IsFinish(String alertmessage) {
+        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                switch (which) {
+                    case DialogInterface.BUTTON_POSITIVE:
+                        InputActivity.super.onBackPressed();
+                        android.os.Process.killProcess(android.os.Process.myPid());
+                        break;
+                    case DialogInterface.BUTTON_NEGATIVE:
+                        break;
+                }
+            }
+        };
+        AlertDialog.Builder builder = new AlertDialog.Builder(this);
+        builder.setMessage(alertmessage)
+                .setPositiveButton("Yes", dialogClickListener)
+                .setNegativeButton("No", dialogClickListener).show();
+    }
+
+    public void showAlertDialog (final View v) {
+        AlertDialog.Builder alert = new AlertDialog.Builder(this);
+        alert.setMessage("Are you sure you want to end this match?");
+        alert.setTitle("Sports Recorder");
+        alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                match.setDone(true);
+                Intent intent = new Intent(InputActivity.this, GameStats.class);
+                intent.putExtra("matchId", matchId);
+                startActivity(intent);
+            }
+        });
+
+        alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+
+            }
+        });
+
+        alert.create().show();
+    }
+
+    /* ================================================================================================================================================= */
+    /* ================================================================== SAVE MATCH =================================================================== */
+    /* ================================================================================================================================================= */
+
+
+    public void saveMatchInfo() {
+        SharedPreferences sharedPreferences = getSharedPreferences(MATCH, MODE_PRIVATE);
+        SharedPreferences.Editor editor = sharedPreferences.edit();
+
+        savePeriodInfo();
+        editor.putString(matchId, new Gson().toJson(match, Match.class));
+
+        editor.commit();
+//        editor.apply();
+    }
+
+    /* ================================================================================================================================================= */
+    /* ============================================================== ANDROID LIFE CYCLE =============================================================== */
+    /* ================================================================================================================================================= */
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        saveMatchInfo();
+    }
+
+    @Override
+    public void onBackPressed() {
+        IsFinish("Are you sure you want to end this match? \nYour game will not be saved.");
+    }
+    private void init_bottomsheet() {
+        this.linearLayoutBSheet = findViewById(R.id.periodSheet);
+        this.bottomSheetBehavior = BottomSheetBehavior.from(linearLayoutBSheet);
+        this.tbUpDown = findViewById(R.id.toggleButton_black);
+
+    }
+
+
+    private void populateRecyclerView() {
+        stringArrayList.clear();
+        for (int i = 0; i < actions.size(); i++){
+            stringArrayList.add(actions.get(i));
+
+        }
+
+        mAdapter = new RecyclerViewAdapter(stringArrayList);
+        recyclerView.setAdapter(mAdapter);
+
+    }
+
+    private void enableSwipeToDeleteAndUndo() {
+
+        SwipeToDeleteCallback swipeToDeleteCallback = new SwipeToDeleteCallback(this) {
+            @Override
+            public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
+
+
+
+                final int position = viewHolder.getAdapterPosition();
+                final String item = mAdapter.getData().get(position);
+                mAdapter.removeItem(position);
+
+                final Action temp_action = history.get(position);
+                Log.e("TEST", "" + position);
+                undoSpecificAction(history.get(position), position);
+
+
+
+                Snackbar snackbar = Snackbar
+                        .make(coordinatorLayout, "Action was deleted.", Snackbar.LENGTH_LONG);
+                snackbar.setAction("UNDO", new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+
+                        mAdapter.restoreItem(item, position);
+                        recyclerView.scrollToPosition(position);
+                        setLastAction(temp_action);
+                        if(temp_action.getTeamName().equals(period.getOpponent().getName())){
+                            //opponent
+
+                            oppScore+= temp_action.point;
+                            Log.e("TEST", "" + temp_action.point);
+                            history.insertElementAt(temp_action, position);
+                            opponentScoreView.setText(String.valueOf(oppScore));
+                        }
+
+                        else{
+
+                            kidScore += temp_action.point;
+
+                            myScoreView.setText(String.valueOf(kidScore + othersScore));
+                        }
+
+                    }
+                });
+
+                snackbar.setActionTextColor(Color.YELLOW);
+                snackbar.show();
+
+            }
+        };
+
+        ItemTouchHelper itemTouchhelper = new ItemTouchHelper(swipeToDeleteCallback);
+        itemTouchhelper.attachToRecyclerView(recyclerView);
+    }
+
+
+}
diff --git a/part3/MainActivity.java b/part3/MainActivity.java
new file mode 100644
index 0000000..6d07d75
--- /dev/null
+++ b/part3/MainActivity.java
@@ -0,0 +1,212 @@
+package com.cs498MD.SportsRecorder;
+
+import android.content.SharedPreferences;
+import android.graphics.Color;
+import android.graphics.Typeface;
+
+import android.content.Intent;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ToggleButton;
+
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class MainActivity extends AppCompatActivity implements View.OnClickListener {
+
+
+    private ArrayList<String> matchNameArray = new ArrayList<>();
+    private ArrayList<String> matchIdArray = new ArrayList<>();
+    private MyCustomAdapter adapter;
+
+    //bottom sheet
+    private BottomSheetBehavior bottomSheetBehavior;
+    private LinearLayout linearLayoutBSheet;
+    private ToggleButton tbUpDown;
+
+
+    private Button createBtn;
+    private EditText userInputMatchName;
+    private EditText userInputKidName;
+
+    private String MATCH = "match";
+
+    private boolean isNumeric(String num) {
+        return num.matches("[0-9]+");
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_match_list);
+
+        init_bottomsheet();
+        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
+
+        tbUpDown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if(isChecked){
+                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
+                }else{
+                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
+                }
+            }
+        });
+
+        bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
+            @Override
+            public void onStateChanged(View view, int newState) {
+                if(newState == BottomSheetBehavior.STATE_EXPANDED){
+                    tbUpDown.setChecked(true);
+                }else if(newState == BottomSheetBehavior.STATE_COLLAPSED){
+                    tbUpDown.setChecked(false);
+                }
+            }
+
+            @Override
+            public void onSlide(View view, float v) {
+
+            }
+        });
+
+        ActionBar bar = getSupportActionBar();
+        bar.setTitle("Matches");
+
+        SharedPreferences sharedPreferences = getSharedPreferences(MATCH, MODE_PRIVATE);
+        Gson gson = new Gson();
+
+        Map<String, ?> allEntries = sharedPreferences.getAll();
+        SortedSet<Integer> keys = new TreeSet<>();
+
+        for (String key : allEntries.keySet()) {
+            if (!isNumeric(key)) {
+                continue;
+            }
+
+            keys.add(Integer.valueOf(key));
+        }
+
+        Log.d("KEYS", keys.toString());
+
+        for (Integer matchId : keys) {
+            String matchJson = sharedPreferences.getString(matchId.toString(), "");
+            Match match = gson.fromJson(matchJson, Match.class);
+
+            matchNameArray.add(match.getName());
+            matchIdArray.add(matchId.toString());            // do something
+        }
+
+        adapter = new MyCustomAdapter(matchNameArray, matchIdArray, this, MainActivity.this);
+
+        ListView listView = (ListView) findViewById(R.id.matchList);
+        listView.setEmptyView(findViewById(R.id.noMatches));
+        listView.setAdapter(adapter);
+
+        createBtn.setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View v) {
+        SharedPreferences sharedPreferences = getSharedPreferences("match", MODE_PRIVATE);
+        int matchCount = sharedPreferences.getInt("matchCount", -1);
+
+        matchCount++;
+        String matchName = "Match " + matchCount;
+
+        SharedPreferences.Editor editor = sharedPreferences.edit();
+        editor.putInt("matchCount", matchCount);
+        editor.putString("matchId", matchName);
+        editor.apply();
+
+        if(v.getId() == R.id.btnCreate){
+
+            Log.e("TEST_SHEET", "Create Match Clicked");
+            Log.e("TEST_SHEET", "Match: " +userInputMatchName.getText().toString());
+            Log.e("TEST_SHEET", "Kid: " + userInputKidName.getText().toString());
+            if(userInputMatchName.getText().toString().equals("")){
+                //user did not enter match name
+                Toast.makeText(this, "Please Enter a Match Name", Toast.LENGTH_SHORT).show();
+
+            }
+            if(userInputKidName.getText().toString().equals("")){
+                //user did not enter kid name
+
+            }
+
+            //TODO: Change match info details. But right now can be used for testing purpose
+            matchNameArray.add(userInputMatchName.getText().toString());
+
+            matchIdArray.add("" + matchCount);
+            adapter.notifyDataSetChanged();
+
+            Intent intent = new Intent(this, InputActivity.class);
+            intent.putExtra("matchId", Integer.toString(matchCount));
+            intent.putExtra("matchName", userInputMatchName.getText().toString());
+            intent.putExtra("kidName", userInputKidName.getText().toString());
+            startActivity(intent);
+
+
+        }
+    }
+
+    //bottom sheet
+    private void init_bottomsheet() {
+        this.linearLayoutBSheet = findViewById(R.id.bottomSheet);
+        this.bottomSheetBehavior = BottomSheetBehavior.from(linearLayoutBSheet);
+        this.tbUpDown = findViewById(R.id.toggleButton);
+
+        this.createBtn = findViewById(R.id.btnCreate);
+        this.userInputKidName = findViewById(R.id.kidNameText);
+        this.userInputMatchName = findViewById(R.id.matchNameText);
+
+    }
+
+    private SimpleAdapter getAdapterListViewCT(ArrayList<Map<String, Object>> lista) {
+        return new SimpleAdapter(this, lista,
+                android.R.layout.simple_list_item_2, new String[]{"Cantante", "Titulo"},
+                new int[]{android.R.id.text1, android.R.id.text2}) {
+
+            @Override
+            public View getView(int position, View convertView, @NonNull ViewGroup parent) {
+                View view = super.getView(position, convertView, parent);
+
+                TextView txtNombre = view.findViewById(android.R.id.text1);
+                txtNombre.setTypeface(Typeface.DEFAULT_BOLD);
+
+                TextView txtCorreo = view.findViewById(android.R.id.text2);
+                txtCorreo.setTextColor(Color.DKGRAY);
+
+                return view;
+            }
+        };
+    }
+
+    private int getRandom() {
+        return (int) Math.floor(Math.random() * 100);
+    }
+}
\ No newline at end of file
diff --git a/part3/Match.java b/part3/Match.java
new file mode 100644
index 0000000..50f5007
--- /dev/null
+++ b/part3/Match.java
@@ -0,0 +1,49 @@
+package com.cs498MD.SportsRecorder;
+import java.util.Stack;
+
+public class Match {
+    private int id;
+    private String name;
+    private Period[] periods = new Period[5];
+    private boolean isDone;
+
+    public Match(int id) {
+        this.id = id;
+        this.name = "Match " + id;
+        for (int i = 0; i < periods.length; i++) {
+            periods[i] = new Period();
+        }
+    }
+
+    public boolean isDone() {
+        return isDone;
+    }
+
+    public void setDone(boolean done) {
+        isDone = done;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Period[] getPeriods() {
+        return periods;
+    }
+
+    public void setPeriods(Period[] periods) {
+        this.periods = periods;
+    }
+}
diff --git a/part3/MatchList.java b/part3/MatchList.java
new file mode 100644
index 0000000..81cdd4b
--- /dev/null
+++ b/part3/MatchList.java
@@ -0,0 +1,13 @@
+package com.cs498MD.SportsRecorder;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class MatchList extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_match_list);
+    }
+}
diff --git a/part3/MyCustomAdapter.java b/part3/MyCustomAdapter.java
new file mode 100644
index 0000000..3fcea42
--- /dev/null
+++ b/part3/MyCustomAdapter.java
@@ -0,0 +1,127 @@
+package com.cs498MD.SportsRecorder;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.TextView;
+
+
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+
+import static android.content.Context.MODE_PRIVATE;
+
+public class MyCustomAdapter extends BaseAdapter {
+    private ArrayList<String> list;
+    private ArrayList<String> matchIdList;
+    private Context context;
+    private Activity activity;
+
+    private String MATCH = "match";
+
+    public MyCustomAdapter(ArrayList<String> list, ArrayList<String> matchIdList, Context context, Activity activity) {
+        this.list = list;
+        this.context = context;
+        this.activity = activity;
+        this.matchIdList = matchIdList;
+    }
+
+    public MyCustomAdapter(ArrayList<String> list,  Context context, Activity activity) {
+        this.list = list;
+        this.context = context;
+        this.activity = activity;
+
+    }
+
+    @Override
+    public int getCount() {
+        return list.size();
+    }
+
+    @Override
+    public Object getItem(int pos) {
+        return list.get(pos);
+    }
+
+    @Override
+    public long getItemId(int pos) {
+        return 0;
+        //just return 0 if your list items do not have an Id variable.
+    }
+
+    public String getMatchId(int pos) {
+        return matchIdList.get(pos);
+    }
+    
+    public void clear() {
+        list.clear();
+    }
+
+    @Override
+    public View getView(final int position, View convertView, final ViewGroup parent) {
+        View view = convertView;
+        if (view == null) {
+            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            view = inflater.inflate(R.layout.match_list_layout, null);
+        }
+
+        //Handle TextView and display string from your list
+        TextView listItemText = (TextView)view.findViewById(R.id.match_item_string);
+        listItemText.setText(list.get(position));
+
+        //Handle buttons and add onClickListeners
+        Button delete_btn = (Button)view.findViewById(R.id.delete_btn);
+        Button viewBtn = (Button)view.findViewById(R.id.view_btn);
+
+        delete_btn.setOnClickListener(new View.OnClickListener(){
+            @Override
+            public void onClick(View v) {
+                //do something
+                DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        switch (which) {
+                            case DialogInterface.BUTTON_POSITIVE:
+                                SharedPreferences sharedPreferences = context.getSharedPreferences(MATCH, MODE_PRIVATE);
+                                sharedPreferences.edit().remove(getMatchId(position)).apply();
+
+                                list.remove(position); //or some other task
+                                matchIdList.remove(position);
+                                notifyDataSetChanged();
+
+                            case DialogInterface.BUTTON_NEGATIVE:
+                                break;
+                        }
+                    }
+                };
+
+                AlertDialog.Builder builder = new AlertDialog.Builder(context);
+                builder.setMessage("Are you sure you want to delete this match?").setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener).show();
+            }
+        });
+        viewBtn.setOnClickListener(new View.OnClickListener(){
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent(v.getContext(), GameStats.class);
+
+                intent.putExtra("matchId", matchIdList.get(position));
+                v.getContext().startActivity(intent);
+            }
+        });
+
+        return view;
+    }
+
+
+}
\ No newline at end of file
diff --git a/part3/Period.java b/part3/Period.java
new file mode 100644
index 0000000..953c64f
--- /dev/null
+++ b/part3/Period.java
@@ -0,0 +1,49 @@
+package com.cs498MD.SportsRecorder;
+
+import java.util.Stack;
+
+public class Period {
+    private Team others;
+    private Team kid;
+    private Team opponent;
+    private Stack<Action> history;
+
+    public Period() {
+        this.others = new Team("My Team (Others)");
+        this.kid = new Team("My Kid");
+        this.opponent = new Team("Opponent Team");
+        this.history = new Stack<>();
+    }
+
+    public Team getOthers() {
+        return others;
+    }
+
+    public void setOthers(Team others) {
+        this.others = others;
+    }
+
+    public Team getKid() {
+        return kid;
+    }
+
+    public void setKid(Team kid) {
+        this.kid = kid;
+    }
+
+    public Team getOpponent() {
+        return opponent;
+    }
+
+    public void setOpponent(Team opponent) {
+        this.opponent = opponent;
+    }
+
+    public Stack<Action> getHistory() {
+        return history;
+    }
+
+    public void setHistory(Stack<Action> history) {
+        this.history = history;
+    }
+}
diff --git a/part3/RecyclerViewAdapter.java b/part3/RecyclerViewAdapter.java
new file mode 100644
index 0000000..787f030
--- /dev/null
+++ b/part3/RecyclerViewAdapter.java
@@ -0,0 +1,90 @@
+package com.cs498MD.SportsRecorder;
+
+
+
+import android.graphics.Color;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.google.android.material.snackbar.Snackbar;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> {
+
+    private ArrayList<String> data;
+
+    public class MyViewHolder extends RecyclerView.ViewHolder {
+
+        private TextView mTitle;
+        RelativeLayout relativeLayout;
+
+
+
+        public MyViewHolder(View itemView) {
+            super(itemView);
+
+
+            mTitle = itemView.findViewById(R.id.txtTitle);
+
+        }
+
+//        @Override
+//        public void onClick(View v) {
+//            if (v.getId() == R.id.action_delete_btn){
+//                Log.e("TEST", "Action deleted");
+//            }
+//
+//        }
+    }
+
+    public RecyclerViewAdapter(ArrayList<String> data) {
+        this.data = data;
+    }
+
+    @Override
+    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_row, parent, false);
+        return new MyViewHolder(itemView);
+    }
+
+    @Override
+    public void onBindViewHolder(final MyViewHolder holder, int position) {
+        holder.mTitle.setText(data.get(position));
+
+
+    }
+
+    @Override
+    public int getItemCount() {
+        return data.size();
+    }
+
+
+    public void removeItem(int position) {
+        data.remove(position);
+        notifyItemRemoved(position);
+    }
+
+    public void restoreItem(String item, int position) {
+        data.add(position, item);
+        notifyItemInserted(position);
+    }
+
+    public ArrayList<String> getData() {
+        return data;
+    }
+
+
+}
+
+
+
diff --git a/part3/SwipeToDeleteCallback.java b/part3/SwipeToDeleteCallback.java
new file mode 100644
index 0000000..20a1fda
--- /dev/null
+++ b/part3/SwipeToDeleteCallback.java
@@ -0,0 +1,102 @@
+package com.cs498MD.SportsRecorder;
+
+
+
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.ItemTouchHelper;
+import androidx.recyclerview.widget.RecyclerView;
+
+abstract public class SwipeToDeleteCallback extends ItemTouchHelper.Callback {
+
+    Context mContext;
+    private Paint mClearPaint;
+    private ColorDrawable mBackground;
+    private int backgroundColor;
+    private Drawable deleteDrawable;
+    private int intrinsicWidth;
+    private int intrinsicHeight;
+
+
+    SwipeToDeleteCallback(Context context) {
+        mContext = context;
+        mBackground = new ColorDrawable();
+        backgroundColor = Color.parseColor("#b80f0a");
+        mClearPaint = new Paint();
+        mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
+        deleteDrawable = ContextCompat.getDrawable(mContext, R.drawable.ic_icons8_trash_can);
+        intrinsicWidth = deleteDrawable.getIntrinsicWidth();
+        intrinsicHeight = deleteDrawable.getIntrinsicHeight();
+
+
+    }
+
+
+    @Override
+    public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
+        return makeMovementFlags(0, ItemTouchHelper.LEFT);
+    }
+
+    @Override
+    public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder viewHolder1) {
+        return false;
+    }
+
+    @Override
+    public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
+        super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+
+        View itemView = viewHolder.itemView;
+        int itemHeight = itemView.getHeight();
+
+        boolean isCancelled = dX == 0 && !isCurrentlyActive;
+
+        if (isCancelled) {
+            clearCanvas(c, itemView.getRight() + dX, (float) itemView.getTop(), (float) itemView.getRight(), (float) itemView.getBottom());
+            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+            return;
+        }
+
+        mBackground.setColor(backgroundColor);
+        mBackground.setBounds(itemView.getRight() + (int) dX, itemView.getTop(), itemView.getRight(), itemView.getBottom());
+        mBackground.draw(c);
+
+        int deleteIconTop = itemView.getTop() + (itemHeight - intrinsicHeight) / 2;
+        int deleteIconMargin = (itemHeight - intrinsicHeight) / 2;
+        int deleteIconLeft = itemView.getRight() - deleteIconMargin - intrinsicWidth;
+        int deleteIconRight = itemView.getRight() - deleteIconMargin;
+        int deleteIconBottom = deleteIconTop + intrinsicHeight;
+
+
+        deleteDrawable.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom);
+        deleteDrawable.draw(c);
+
+        super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+
+
+    }
+
+    private void clearCanvas(Canvas c, Float left, Float top, Float right, Float bottom) {
+        c.drawRect(left, top, right, bottom, mClearPaint);
+
+    }
+
+    @Override
+    public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
+        return 0.7f;
+    }
+}
+
+
diff --git a/part3/Team.java b/part3/Team.java
new file mode 100644
index 0000000..1fa25cb
--- /dev/null
+++ b/part3/Team.java
@@ -0,0 +1,64 @@
+package com.cs498MD.SportsRecorder;
+
+import java.util.ArrayList;
+
+public class Team {
+    private String name;
+    private int score;
+    private int onePoint;
+    private int twoPoint;
+    private int threePoint;
+    private int miss;
+
+    public Team(String name) {
+        this.name = name;
+    }
+
+    public int getScore() {
+        return score;
+    }
+
+    public void setScore(int score) {
+        this.score = score;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getOnePoint() {
+        return onePoint;
+    }
+
+    public void setOnePoint(int onePoint) {
+        this.onePoint = onePoint;
+    }
+
+    public int getTwoPoint() {
+        return twoPoint;
+    }
+
+    public void setTwoPoint(int twoPoint) {
+        this.twoPoint = twoPoint;
+    }
+
+    public int getThreePoint() {
+        return threePoint;
+    }
+
+    public void setThreePoint(int threePoint) {
+        this.threePoint = threePoint;
+    }
+
+    public int getMiss() {
+        return miss;
+    }
+
+    public void setMiss(int miss) {
+        this.miss = miss;
+    }
+}
diff --git a/part3/test_activity.java b/part3/test_activity.java
new file mode 100644
index 0000000..a5bf168
--- /dev/null
+++ b/part3/test_activity.java
@@ -0,0 +1,96 @@
+package com.cs498MD.SportsRecorder;
+
+
+import android.graphics.Color;
+import android.os.Bundle;
+
+import android.view.View;
+
+import com.google.android.material.snackbar.Snackbar;
+
+import java.util.ArrayList;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.recyclerview.widget.ItemTouchHelper;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+public class test_activity extends AppCompatActivity {
+
+
+    RecyclerView recyclerView;
+    RecyclerViewAdapter mAdapter;
+    ArrayList<String> stringArrayList = new ArrayList<>();
+    CoordinatorLayout coordinatorLayout;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.test_recycle);
+
+        recyclerView = findViewById(R.id.recyclerView);
+        coordinatorLayout = findViewById(R.id.coordinatorLayout);
+
+        populateRecyclerView();
+        enableSwipeToDeleteAndUndo();
+
+
+    }
+
+    private void populateRecyclerView() {
+        stringArrayList.add("Item 1");
+        stringArrayList.add("Item 2");
+        stringArrayList.add("Item 3");
+        stringArrayList.add("Item 4");
+        stringArrayList.add("Item 5");
+        stringArrayList.add("Item 6");
+        stringArrayList.add("Item 7");
+        stringArrayList.add("Item 8");
+        stringArrayList.add("Item 9");
+        stringArrayList.add("Item 10");
+
+        mAdapter = new RecyclerViewAdapter(stringArrayList);
+        recyclerView.setAdapter(mAdapter);
+
+
+    }
+
+    private void enableSwipeToDeleteAndUndo() {
+        SwipeToDeleteCallback swipeToDeleteCallback = new SwipeToDeleteCallback(this) {
+            @Override
+            public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
+
+
+                final int position = viewHolder.getAdapterPosition();
+                final String item = mAdapter.getData().get(position);
+
+                mAdapter.removeItem(position);
+
+
+                Snackbar snackbar = Snackbar
+                        .make(coordinatorLayout, "Item was removed from the list.", Snackbar.LENGTH_LONG);
+                snackbar.setAction("UNDO", new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+
+                        mAdapter.restoreItem(item, position);
+                        recyclerView.scrollToPosition(position);
+                    }
+                });
+
+                snackbar.setActionTextColor(Color.YELLOW);
+                snackbar.show();
+
+            }
+        };
+
+        ItemTouchHelper itemTouchhelper = new ItemTouchHelper(swipeToDeleteCallback);
+        itemTouchhelper.attachToRecyclerView(recyclerView);
+    }
+
+
+}
+
+
-- 
GitLab