Skip to content

Commit c9f017d

Browse files
committed
Added Comments to Combat and Added InputFilters to All Title inputs
1 parent df710df commit c9f017d

File tree

8 files changed

+140
-28
lines changed

8 files changed

+140
-28
lines changed

app/src/main/java/com/example/bored_bard/Combat/CombatAdapter.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,33 @@
2222
import java.util.ArrayList;
2323
import java.util.jar.Attributes;
2424

25-
25+
/**
26+
* @author Andrew MacMurray - FrozenDrew
27+
*/
2628
public class CombatAdapter extends RecyclerView.Adapter<CombatAdapter.CombatHolder>{
2729
Context context;
2830
ArrayList<Player> playerlist;
2931

32+
33+
/**
34+
*
35+
* @param context is context?
36+
* @param playerlist is the ArrayList of Players that will be used to set the CombatCard View
37+
* With the Data From the RealTime Database
38+
*/
3039
public CombatAdapter(Context context, ArrayList<Player> playerlist) {
3140
this.context = context;
3241
this.playerlist = playerlist;
3342
}
3443

44+
/**
45+
*
46+
* @param parent The ViewGroup into which the new View will be added after it is bound to
47+
* an adapter position.
48+
* @param viewType The view type of the new View.
49+
*
50+
* @return view is the CombatCard View
51+
*/
3552
@NonNull
3653
@Override
3754
public CombatHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@@ -40,27 +57,38 @@ public CombatHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
4057
return new CombatHolder(view);
4158
}
4259

60+
/**
61+
*
62+
* @param holder The ViewHolder which should be updated to represent the contents of the
63+
* item at the given position in the data set.
64+
* @param position The position of the item within the adapter's data set.
65+
*/
4366
@Override
4467
public void onBindViewHolder(@NonNull CombatHolder holder, int position) {FirebaseUser user;
4568

4669

47-
holder.Name.setText(playerlist.get(position).getName());
70+
//Sets the CombatCard with Values from the ArrayList
71+
holder.Name.setText(playerlist.get(position).getName());
4872
holder.HP.setText(playerlist.get(position).getHp());
4973
holder.AC.setText(playerlist.get(position).getAc());
5074

5175

5276

5377
}
5478

79+
/**
80+
*
81+
* @return the size of the playerList
82+
*/
5583
@Override
5684
public int getItemCount() {
5785
return playerlist.size();
5886
}
5987

60-
public void onBindViewHolder(String s) {
61-
}
62-
6388

89+
/**
90+
* Stores the Views that are needed for the CombatCard
91+
*/
6492
public static class CombatHolder extends RecyclerView.ViewHolder{
6593
TextView Name, AC;
6694
EditText HP, IntRoll;

app/src/main/java/com/example/bored_bard/Combat/combat_activity.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.ArrayList;
3333

3434
/**
35-
* @author Caroline Barrineau
35+
* @author Andrew MacMurray - FrozenDrew
3636
*/
3737
public class combat_activity extends Activity {
3838
FirebaseAuth mAuth;
@@ -57,34 +57,42 @@ protected void onCreate(Bundle savedInstanceState) {
5757
database = FirebaseDatabase.getInstance();
5858

5959

60-
61-
62-
63-
60+
/**
61+
* Gets the Title pointer for the Database
62+
*/
6463
Bundle bundle = getIntent().getExtras();
6564
if(bundle != null){
6665
combatTitle.setText(bundle.getString("CombatTitle"));
67-
//CombatPath = bundle.getString("CombatTitle");
66+
6867
}
6968
String Title = String.valueOf(combatTitle.getText());
7069

71-
//Firebase calls
7270

7371

7472

73+
//Creates an ArrayList for the Adapter to pull information from
7574
playerlist = new ArrayList<>();
7675

76+
//Calls RecyclerView
7777
RecyclerView recyclerView = findViewById(R.id.combatRecycler);
7878

7979
GridLayoutManager gridLayoutManager = new GridLayoutManager(combat_activity.this, 1);
8080
recyclerView.setLayoutManager(gridLayoutManager);
8181

82+
//Calls the CombatApdater
8283
CombatAdapter playerAdapter = new CombatAdapter(combat_activity.this, playerlist);
8384

85+
//Sets the RecyclerView to the CombatAdpater
8486
recyclerView.setAdapter(playerAdapter);
8587

88+
//FireBase DatabaseReference to find the Players
8689
databaseReference = database.getReference(username).child("Campaigns").child(Title).child("Players");
8790

91+
/**
92+
* Adds players to the ArrayList playerList from the Firebase Realtime Database
93+
* The CombatAdapter will set the CombatCard with the Values from the playerList
94+
* Then the RecyclerView will Display the CombatCard
95+
*/
8896
eventListener = databaseReference.addValueEventListener(new ValueEventListener() {
8997
@Override
9098
public void onDataChange(@NonNull DataSnapshot snapshot) {
@@ -104,15 +112,15 @@ public void onCancelled(@NonNull DatabaseError error) {
104112
}
105113
});
106114

107-
playerAdapter.onBindViewHolder(Title = String.valueOf(combatTitle));
115+
108116

109117

110118

111119
//button calls
112120
backBtn = findViewById(R.id.CombatbackBtn);
113-
114-
115-
121+
/**
122+
* Will send the User back to the Campaign Menu with the Title pointer
123+
*/
116124
backBtn.setOnClickListener(new View.OnClickListener() {
117125
@Override
118126
public void onClick(View view) {

app/src/main/java/com/example/bored_bard/UI_files/Register.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import android.content.Intent;
66
import android.os.Bundle;
7+
import android.text.InputFilter;
8+
import android.text.Spanned;
79
import android.text.TextUtils;
810
import android.util.Log;
911
import android.view.View;
@@ -82,6 +84,21 @@ public void onClick(View view) {
8284
}
8385
});
8486

87+
InputFilter filter = new InputFilter() {
88+
public CharSequence filter(CharSequence source, int start, int end,
89+
Spanned dest, int dstart, int dend) {
90+
for (int i = start; i < end; i++) {
91+
char c = source.charAt(i);
92+
if (c == '.' || c == '#' || c == '$' || c == '[' || c == ']') {
93+
return ""; // return an empty string to prevent the character from being entered
94+
}
95+
}
96+
return null; // let the character be entered
97+
}
98+
};
99+
editUsername.setFilters(new InputFilter[] {filter});
100+
101+
85102
/**
86103
* Will Register a User using Email, Password, and Username
87104
* If Email is blank will prompt the user to Enter an Email

app/src/main/java/com/example/bored_bard/UI_files/addCampaign_activity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import android.app.Activity;
2525
import android.os.Bundle;
26+
import android.text.InputFilter;
27+
import android.text.Spanned;
2628
import android.text.TextUtils;
2729
import android.widget.Button;
2830
import android.view.View;
@@ -58,6 +60,22 @@ protected void onCreate(Bundle savedInstanceState) {
5860
user = mAuth.getCurrentUser();
5961
databaseReference = FirebaseDatabase.getInstance().getReference();
6062

63+
64+
InputFilter filter = new InputFilter() {
65+
public CharSequence filter(CharSequence source, int start, int end,
66+
Spanned dest, int dstart, int dend) {
67+
for (int i = start; i < end; i++) {
68+
char c = source.charAt(i);
69+
if (c == '.' || c == '#' || c == '$' || c == '[' || c == ']') {
70+
return ""; // return an empty string to prevent the character from being entered
71+
}
72+
}
73+
return null; // let the character be entered
74+
}
75+
};
76+
77+
CampaignTitle.setFilters(new InputFilter[] {filter});
78+
6179
String campaignTitle = CampaignTitle.getText().toString();
6280
String campaignDescription = CampaignInfo.getText().toString();
6381

@@ -70,6 +88,8 @@ protected void onCreate(Bundle savedInstanceState) {
7088
createCampaign.setOnClickListener(new View.OnClickListener() {
7189
@Override
7290
public void onClick(View view) {
91+
92+
7393
String username = user.getDisplayName(), Title;
7494

7595
Title = String.valueOf(CampaignTitle.getText());

app/src/main/java/com/example/bored_bard/notes/AddNotes.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import android.content.Intent;
77
import android.os.Bundle;
8+
import android.text.InputFilter;
9+
import android.text.Spanned;
810
import android.text.TextUtils;
911
import android.view.View;
1012
import android.widget.EditText;
@@ -60,6 +62,19 @@ protected void onCreate(Bundle savedInstanceState) {
6062
CNTitle.setText(bundle.getString("Title"));
6163

6264
}
65+
InputFilter filter = new InputFilter() {
66+
public CharSequence filter(CharSequence source, int start, int end,
67+
Spanned dest, int dstart, int dend) {
68+
for (int i = start; i < end; i++) {
69+
char c = source.charAt(i);
70+
if (c == '.' || c == '#' || c == '$' || c == '[' || c == ']') {
71+
return ""; // return an empty string to prevent the character from being entered
72+
}
73+
}
74+
return null; // let the character be entered
75+
}
76+
};
77+
titleInput.setFilters(new InputFilter[] {filter});
6378

6479

6580
//Creates a New Note and returns the user to the NotesList page

app/src/main/java/com/example/bored_bard/notes/EditNote.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import android.content.DialogInterface;
1515
import android.content.Intent;
1616
import android.os.Bundle;
17+
import android.text.InputFilter;
18+
import android.text.Spanned;
1719
import android.text.TextUtils;
1820
import android.view.View;
1921
import android.widget.EditText;
@@ -61,6 +63,21 @@ protected void onCreate(Bundle savedInstanceState) {
6163
id = bundle.getString("id");
6264
}
6365

66+
InputFilter filter = new InputFilter() {
67+
public CharSequence filter(CharSequence source, int start, int end,
68+
Spanned dest, int dstart, int dend) {
69+
for (int i = start; i < end; i++) {
70+
char c = source.charAt(i);
71+
if (c == '.' || c == '#' || c == '$' || c == '[' || c == ']') {
72+
return ""; // return an empty string to prevent the character from being entered
73+
}
74+
}
75+
return null; // let the character be entered
76+
}
77+
};
78+
79+
ETitle.setFilters(new InputFilter[] {filter});
80+
6481
//Calls the Firebase References from the RealTime database
6582
firebaseDatabase = FirebaseDatabase.getInstance();
6683
reference = FirebaseDatabase.getInstance().getReference(username).child("Campaigns").child(CTitle.getText().toString()).child("Notes").child(id);

app/src/main/java/com/example/bored_bard/player/addPlayer.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import android.content.Intent;
66
import android.os.Bundle;
7+
import android.text.InputFilter;
8+
import android.text.Spanned;
79
import android.view.View;
810
import android.widget.Button;
911
import android.widget.TextView;
@@ -60,6 +62,20 @@ protected void onCreate(Bundle savedInstanceState) {
6062
Title = bundle.getString("Title");
6163
}
6264

65+
InputFilter filter = new InputFilter() {
66+
public CharSequence filter(CharSequence source, int start, int end,
67+
Spanned dest, int dstart, int dend) {
68+
for (int i = start; i < end; i++) {
69+
char c = source.charAt(i);
70+
if (c == '.' || c == '#' || c == '$' || c == '[' || c == ']') {
71+
return ""; // return an empty string to prevent the character from being entered
72+
}
73+
}
74+
return null; // let the character be entered
75+
}
76+
};
77+
Name.setFilters(new InputFilter[] {filter});
78+
6379

6480
reference = FirebaseDatabase.getInstance().getReference();
6581

app/src/main/res/layout/activity_add_notes.xml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@
101101
/>
102102

103103
<!-- Back Button -->
104-
<TextView
105-
android:id="@+id/backBtn"
106-
android:layout_width="wrap_content"
107-
android:layout_height="wrap_content"
108-
android:textStyle="bold"
109-
android:text="@string/back"
110-
android:textSize="17sp"
111-
android:textAlignment="center"
112-
android:layout_margin="10dp"
113-
app:layout_constraintStart_toStartOf="@+id/guideline_left"
114-
app:layout_constraintTop_toTopOf="parent" />
115104

116105
<LinearLayout
117106
android:id="@+id/linearLayout"
@@ -155,6 +144,7 @@
155144
android:layout_marginTop="36dp"
156145
android:text="@string/create_note"
157146
android:textColor="@color/white"
147+
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
158148
app:layout_constraintEnd_toStartOf="@+id/guideline_right"
159149
app:layout_constraintStart_toEndOf="@+id/exitButton"
160150
app:layout_constraintTop_toBottomOf="@id/linearLayout" />
@@ -167,8 +157,9 @@
167157
android:layout_marginTop="36dp"
168158
android:text="@string/cancel"
169159
android:textColor="@color/white"
170-
app:layout_constraintStart_toStartOf="@+id/guideline_left"
160+
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
171161
app:layout_constraintEnd_toStartOf="@+id/savebutton"
162+
app:layout_constraintStart_toStartOf="@+id/guideline_left"
172163
app:layout_constraintTop_toBottomOf="@id/linearLayout" />
173164

174165
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)