mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-08 16:28:00 -06:00
Work on scouting reporting
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
import static com.ridgebotics.ridgescout.SettingsVersionStack.latestSettings.settings;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -11,6 +14,13 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataCompareBinding;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataReportBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class CompareFragment extends Fragment {
|
||||
FragmentDataCompareBinding binding;
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
import static com.ridgebotics.ridgescout.SettingsVersionStack.latestSettings.settings;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataReportBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ReportFragment extends Fragment {
|
||||
FragmentDataReportBinding binding;
|
||||
@@ -19,6 +31,91 @@ public class ReportFragment extends Fragment {
|
||||
|
||||
binding = FragmentDataReportBinding.inflate(inflater, container, false);
|
||||
|
||||
getReportMatches();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
public frcMatch[] getTeamMatches(int teamNum){
|
||||
DataManager.reload_event();
|
||||
List<frcMatch> teamMatches = new ArrayList<>();
|
||||
for(int i = 0; i < event.matches.size(); i++){
|
||||
frcMatch match = event.matches.get(i);
|
||||
boolean isTeamMatch = false;
|
||||
isTeamMatch = IntStream.of(match.redAlliance).anyMatch(x -> x == teamNum);
|
||||
isTeamMatch = isTeamMatch || IntStream.of(match.blueAlliance).anyMatch(x -> x == teamNum);
|
||||
if(isTeamMatch)
|
||||
teamMatches.add(match);
|
||||
}
|
||||
return teamMatches.toArray(new frcMatch[0]);
|
||||
}
|
||||
|
||||
private int getMostRecentTeamMatch(int teamNum, int curMatch){
|
||||
frcMatch[] teamMatches = getTeamMatches(teamNum);
|
||||
int maxMatch = - 1;
|
||||
|
||||
for(int i = 0; i < teamMatches.length; i++) {
|
||||
if (teamMatches[i].matchIndex < curMatch &&
|
||||
teamMatches[i].matchIndex > maxMatch) {
|
||||
maxMatch = teamMatches[i].matchIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(maxMatch == -1)
|
||||
return curMatch;
|
||||
else
|
||||
return maxMatch;
|
||||
}
|
||||
|
||||
public void getReportMatches(){
|
||||
// String out = "";
|
||||
int ourTeamNum = settings.get_team_num();
|
||||
frcMatch[] teamMatches = getTeamMatches(ourTeamNum);
|
||||
|
||||
TableRow tr = new TableRow(getContext());
|
||||
|
||||
TextView tv = new TextView(getContext());
|
||||
tv.setText("Team match");
|
||||
tr.addView(tv);
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setText("Most informed match");
|
||||
tr.addView(tv);
|
||||
|
||||
binding.teamMatchesTable.addView(tr);
|
||||
binding.teamMatchesTable.setStretchAllColumns(true);
|
||||
|
||||
for(int i = 0; i < teamMatches.length; i++){
|
||||
tr = new TableRow(getContext());
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setText(String.valueOf(teamMatches[i].matchIndex));
|
||||
tr.addView(tv);
|
||||
|
||||
int maxMatch = -1;
|
||||
for(int a = 0; a < 6; a++){
|
||||
int teamNum = 0;
|
||||
if(a < 3)
|
||||
teamNum = teamMatches[i].redAlliance[a];
|
||||
else
|
||||
teamNum = teamMatches[i].blueAlliance[a-3];
|
||||
|
||||
if(teamNum == ourTeamNum)
|
||||
continue;
|
||||
|
||||
int matchNum = getMostRecentTeamMatch(teamNum, teamMatches[i].matchIndex);
|
||||
if(maxMatch < matchNum)
|
||||
maxMatch = matchNum;
|
||||
}
|
||||
|
||||
|
||||
tv = new TextView(getContext());
|
||||
tv.setText(String.valueOf(maxMatch));
|
||||
tr.addView(tv);
|
||||
|
||||
binding.teamMatchesTable.addView(tr);
|
||||
}
|
||||
// AlertManager.error(out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,29 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/teamMatchesTable"
|
||||
android:layout_width="409dp"
|
||||
android:layout_height="729dp"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginEnd="1dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView4">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TBD"
|
||||
android:textSize="34sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:text="1234"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user