mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Handle matches not being released yet.
This commit is contained in:
@@ -49,12 +49,22 @@ public class dataFragment extends Fragment {
|
||||
submenu = true;
|
||||
});
|
||||
|
||||
binding.searchButton.setOnClickListener(v -> {
|
||||
binding.buttons.setVisibility(View.GONE);
|
||||
binding.searchView.setVisibility(View.VISIBLE);
|
||||
binding.searchView.init(binding, event);
|
||||
submenu = true;
|
||||
});
|
||||
|
||||
show_ui();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public void show_ui(){
|
||||
binding.buttons.setVisibility(View.VISIBLE);
|
||||
binding.overviewView.setVisibility(View.GONE);
|
||||
binding.searchView.setVisibility(View.GONE);
|
||||
submenu = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ public class overviewView extends ScrollView {
|
||||
}
|
||||
tr.addView(text);
|
||||
}
|
||||
binding.matchTable.addView(tr);
|
||||
if(tr != null)
|
||||
binding.matchTable.addView(tr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.astatin3.scoutingapp2025.ui.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentDataBinding;
|
||||
import com.astatin3.scoutingapp2025.types.frcEvent;
|
||||
|
||||
public class searchView extends ConstraintLayout {
|
||||
public searchView(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
public searchView(Context context, AttributeSet attributeSet){
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
FragmentDataBinding binding;
|
||||
|
||||
public void init(FragmentDataBinding binding, frcEvent event){
|
||||
this.binding = binding;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -91,12 +91,12 @@ public class matchScoutingView extends ConstraintLayout {
|
||||
}
|
||||
|
||||
|
||||
public void init(FragmentScoutingBinding tmp_binding){
|
||||
public void init(FragmentScoutingBinding tmp_binding, frcEvent event){
|
||||
binding = tmp_binding;
|
||||
|
||||
alliance_position = latestSettings.settings.get_alliance_pos();
|
||||
evcode = latestSettings.settings.get_evcode();
|
||||
event = frcEvent.decode(fileEditor.readFile(evcode + ".eventdata"));
|
||||
evcode = event.eventCode;
|
||||
this.event = event;
|
||||
username = latestSettings.settings.get_username();
|
||||
|
||||
binding.eventcode.setText(evcode);
|
||||
|
||||
@@ -81,11 +81,11 @@ public class pitScoutingView extends ConstraintLayout {
|
||||
}
|
||||
|
||||
|
||||
public void init(FragmentScoutingBinding tmp_binding){
|
||||
public void init(FragmentScoutingBinding tmp_binding, frcEvent event){
|
||||
binding = tmp_binding;
|
||||
|
||||
evcode = latestSettings.settings.get_evcode();
|
||||
event = frcEvent.decode(fileEditor.readFile(evcode + ".eventdata"));
|
||||
evcode = event.eventCode;
|
||||
this.event = event;
|
||||
username = latestSettings.settings.get_username();
|
||||
|
||||
binding.eventcode.setText(evcode);
|
||||
|
||||
@@ -14,6 +14,8 @@ import androidx.fragment.app.Fragment;
|
||||
import com.astatin3.scoutingapp2025.MainActivity;
|
||||
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
||||
import com.astatin3.scoutingapp2025.types.frcEvent;
|
||||
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
||||
|
||||
public class scoutingFragment extends Fragment {
|
||||
|
||||
@@ -30,7 +32,14 @@ public class scoutingFragment extends Fragment {
|
||||
binding.matchScoutingView.setVisibility(View.GONE);
|
||||
binding.pitScoutingView.setVisibility(View.GONE);
|
||||
|
||||
if(latestSettings.settings.get_evcode().equals("unset")){
|
||||
String evcode = latestSettings.settings.get_evcode();
|
||||
frcEvent event = frcEvent.decode(fileEditor.readFile(evcode + ".eventdata"));
|
||||
|
||||
if(event.matches.isEmpty())
|
||||
binding.matchScoutingButton.setVisibility(View.GONE);
|
||||
|
||||
|
||||
if(evcode.equals("unset")){
|
||||
binding.noEventError.setVisibility(View.VISIBLE);
|
||||
binding.buttons.setVisibility(View.GONE);
|
||||
is_main_page = false;
|
||||
@@ -39,7 +48,7 @@ public class scoutingFragment extends Fragment {
|
||||
binding.matchScoutingButton.setOnClickListener(v -> {
|
||||
binding.buttons.setVisibility(View.GONE);
|
||||
binding.matchScoutingView.setVisibility(View.VISIBLE);
|
||||
binding.matchScoutingView.init(binding);
|
||||
binding.matchScoutingView.init(binding, event);
|
||||
is_main_page = false;
|
||||
});
|
||||
|
||||
@@ -47,7 +56,7 @@ public class scoutingFragment extends Fragment {
|
||||
binding.pitScoutingView.setVisibility(View.VISIBLE);
|
||||
binding.buttons.setVisibility(View.GONE);
|
||||
// binding.pitScoutArea.setVisibility(View.VISIBLE);
|
||||
binding.pitScoutingView.init(binding);
|
||||
binding.pitScoutingView.init(binding, event);
|
||||
is_main_page = false;
|
||||
});
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.astatin3.scoutingapp2025.types.frcTeam;
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentTransferBinding;
|
||||
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
||||
import com.astatin3.scoutingapp2025.utility.JSONUtil;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -26,6 +27,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -202,7 +204,8 @@ public class TBAView extends ScrollView {
|
||||
Table.bringToFront();
|
||||
|
||||
try {
|
||||
final JSONArray matchData = new JSONArray(matchesString);
|
||||
// final JSONArray matchData = new JSONArray(matchesString);
|
||||
final JSONArray matchData = new JSONArray();
|
||||
final JSONArray teamData = new JSONArray(teamsString);
|
||||
|
||||
String matchKey = eventData.getString("key");
|
||||
@@ -234,15 +237,7 @@ public class TBAView extends ScrollView {
|
||||
tv.setTextSize(28);
|
||||
Table.addView(tv);
|
||||
|
||||
if(matchData.length() == 0){
|
||||
TableRow tr = new TableRow(getContext());
|
||||
addTableText(tr, "This event has no matches released yet...");
|
||||
Table.addView(tr);
|
||||
tr = new TableRow(getContext());
|
||||
addTableText(tr, "Try manually adding practice matches.");
|
||||
Table.addView(tr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Save button
|
||||
Button btn = new Button(getContext());
|
||||
@@ -255,7 +250,130 @@ public class TBAView extends ScrollView {
|
||||
Table.addView(btn);
|
||||
|
||||
|
||||
TableRow tr = new TableRow(getContext());
|
||||
|
||||
|
||||
if(teamData.length() == 0){
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("This event has no teams released yet...");
|
||||
tv.setTextSize(18);
|
||||
Table.addView(tv);
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("This event has no teams released yet...");
|
||||
tv.setTextSize(18);
|
||||
Table.addView(tv);
|
||||
|
||||
btn.setVisibility(View.GONE);
|
||||
return;
|
||||
}else if(matchData.length() == 0){
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("This event has no matches released yet...");
|
||||
tv.setTextSize(18);
|
||||
Table.addView(tv);
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("Try manually adding practice matches.");
|
||||
tv.setTextSize(18);
|
||||
Table.addView(tv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("Teams");
|
||||
tv.setTextSize(28);
|
||||
Table.addView(tv);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int[] teams = new int[teamData.length()];
|
||||
|
||||
for(int i = 0 ; i < teamData.length(); i++){
|
||||
teams[i] = teamData.getJSONObject(i).getInt("team_number");
|
||||
}
|
||||
|
||||
Arrays.sort(teams);
|
||||
|
||||
TableRow tr = null;
|
||||
for(int i=0; i < teamData.length(); i++){
|
||||
// frcTeam team = event.teams.get(i);
|
||||
int num = teams[i];
|
||||
|
||||
if(i % 7 == 0){
|
||||
if(i != 0)
|
||||
Table.addView(tr);
|
||||
tr = new TableRow(getContext());
|
||||
}
|
||||
|
||||
TextView text = new TextView(getContext());
|
||||
text.setTextSize(18);
|
||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||
|
||||
text.setText(String.valueOf(num));
|
||||
// if(fileEditor.fileExist(event.eventCode + "-" + num + ".pitscoutdata")){
|
||||
// text.setBackgroundColor(0x3000FF00);
|
||||
// }else{
|
||||
// text.setBackgroundColor(0x30FF0000);
|
||||
// }
|
||||
tr.addView(text);
|
||||
}
|
||||
if(tr != null)
|
||||
Table.addView(tr);
|
||||
|
||||
final ArrayList<frcMatch> matchesOBJ = new ArrayList<>();
|
||||
|
||||
btn.setOnClickListener(v -> {
|
||||
if(saveData(matchesOBJ, teamData, eventData)){
|
||||
alert("Info", "Saved!");
|
||||
}else{
|
||||
alert("Error", "Error saving files.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText("Matches");
|
||||
tv.setTextSize(28);
|
||||
Table.addView(tv);
|
||||
|
||||
|
||||
|
||||
|
||||
tr = new TableRow(getContext());
|
||||
addTableText(tr, "#");
|
||||
addTableText(tr, "Red-1");
|
||||
addTableText(tr, "Red-2");
|
||||
@@ -266,6 +384,10 @@ public class TBAView extends ScrollView {
|
||||
Table.addView(tr);
|
||||
|
||||
|
||||
if(matchData.length() == 0)
|
||||
return;
|
||||
|
||||
|
||||
final JSONArray sortedMatchData = JSONUtil.sort(matchData, (a, b) -> {
|
||||
JSONObject ja = (JSONObject)a;
|
||||
JSONObject jb = (JSONObject)b;
|
||||
@@ -277,7 +399,6 @@ public class TBAView extends ScrollView {
|
||||
});
|
||||
|
||||
|
||||
final ArrayList<frcMatch> matchesOBJ = new ArrayList<>();
|
||||
boolean toggle = false;
|
||||
int matchCount = 1;
|
||||
|
||||
@@ -335,13 +456,13 @@ public class TBAView extends ScrollView {
|
||||
toggle = !toggle;
|
||||
}
|
||||
|
||||
btn.setOnClickListener(v -> {
|
||||
if(saveData(matchesOBJ, teamData, eventData)){
|
||||
alert("Info", "Saved!");
|
||||
}else{
|
||||
alert("Error", "Error saving files.");
|
||||
}
|
||||
});
|
||||
// btn.setOnClickListener(v -> {
|
||||
// if(saveData(matchesOBJ, teamData, eventData)){
|
||||
// alert("Info", "Saved!");
|
||||
// }else{
|
||||
// alert("Error", "Error saving files.");
|
||||
// }
|
||||
// });
|
||||
|
||||
}catch (JSONException j){
|
||||
j.printStackTrace();
|
||||
|
||||
@@ -5,43 +5,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/no_event_error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="No event has been specified\nPlease select one"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.astatin3.scoutingapp2025.ui.data.overviewView
|
||||
android:id="@+id/overviewView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="60dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/matchTable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.astatin3.scoutingapp2025.ui.data.overviewView>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/buttons"
|
||||
@@ -90,4 +53,68 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/no_event_error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="No event has been specified\nPlease select one"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.astatin3.scoutingapp2025.ui.data.overviewView
|
||||
android:id="@+id/overviewView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="60dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/matchTable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.astatin3.scoutingapp2025.ui.data.overviewView>
|
||||
|
||||
<com.astatin3.scoutingapp2025.ui.data.searchView
|
||||
android:id="@+id/searchView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="60dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<!-- <TableLayout-->
|
||||
<!-- android:id="@+id/matchTable"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent" />-->
|
||||
|
||||
</LinearLayout>
|
||||
</com.astatin3.scoutingapp2025.ui.data.searchView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user