1 Commits

Author SHA1 Message Date
Michael Mikovsky 5a644c6671 WIP 2025-07-27 22:02:23 -06:00
7 changed files with 140 additions and 151 deletions
+4 -2
View File
@@ -57,11 +57,13 @@ dependencies {
implementation(libs.constraintlayout) implementation(libs.constraintlayout)
implementation(libs.lifecycle.livedata.ktx) implementation(libs.lifecycle.livedata.ktx)
implementation(libs.lifecycle.viewmodel.ktx) implementation(libs.lifecycle.viewmodel.ktx)
implementation("androidx.navigation:navigation-fragment:2.8.9") implementation(libs.navigation.fragment.v289)
implementation(libs.navigation.ui) implementation(libs.navigation.ui)
implementation(libs.preference) implementation(libs.preference)
// implementation(libs.support.annotations) // implementation(libs.asynclayoutinflator)
testImplementation(libs.junit) testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit) androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core) androidTestImplementation(libs.espresso.core)
@@ -19,9 +19,12 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.ridgebotics.ridgescout.R;
import com.ridgebotics.ridgescout.types.frcTeam; import com.ridgebotics.ridgescout.types.frcTeam;
import com.ridgebotics.ridgescout.ui.views.FieldBorderedRow; import com.ridgebotics.ridgescout.ui.views.FieldBorderedRow;
import com.ridgebotics.ridgescout.ui.views.RecyclerList;
import com.ridgebotics.ridgescout.ui.views.TeamListOption; import com.ridgebotics.ridgescout.ui.views.TeamListOption;
import com.ridgebotics.ridgescout.utility.DataManager; import com.ridgebotics.ridgescout.utility.DataManager;
import com.ridgebotics.ridgescout.utility.SettingsManager; import com.ridgebotics.ridgescout.utility.SettingsManager;
@@ -44,7 +47,7 @@ public class DataFragment extends Fragment {
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
binding = FragmentDataBinding.inflate(inflater, container, false); binding = FragmentDataBinding.inflate(inflater, container, false);
binding.table.setStretchAllColumns(true); // binding.table.setStretchAllColumns(true);
View root = binding.getRoot(); View root = binding.getRoot();
if(evcode == null || evcode.equals("unset") || event == null){ if(evcode == null || evcode.equals("unset") || event == null){
@@ -86,35 +89,21 @@ public class DataFragment extends Fragment {
public void load_teams(){ public void load_teams(){
int[] teamNums = new int[event.teams.size()]; RecyclerList<frcTeam> list = new RecyclerList<>(getContext());
binding.table.addView(list);
// list.setView
for(int i = 0 ; i < event.teams.size(); i++){ list
teamNums[i] = event.teams.get(i).teamNumber; .setup(R.layout.view_team_option, TeamListOption::new)
} .withLinearLayout()
.withDivider()
Arrays.sort(teamNums); .withItemClickListener((team, position) -> {
TeamsFragment.setTeam(team);
for(int i = 0; i < event.teams.size(); i++){
frcTeam team = null;
for(int a = 0 ; a < event.teams.size(); a++){
if(event.teams.get(a).teamNumber == teamNums[i]){
team = event.teams.get(a);
break;
}
}
assert team != null;
TeamListOption teamRow = new TeamListOption(getContext());
binding.table.addView(teamRow);
teamRow.fromTeam(team);
frcTeam finalTeam = team;
teamRow.setOnClickListener(v -> {
TeamsFragment.setTeam(finalTeam);
((DataParentFragment) getParentFragment()).moveToFragment(new TeamsFragment()); ((DataParentFragment) getParentFragment()).moveToFragment(new TeamsFragment());
// findNavController(this).navigate(R.id.action_navigation_data_parent_to_navigation_data_teams);
}); });
}
list.setItems(event.getTeamsSorted());
} }
public void load_fields(){ public void load_fields(){
DataManager.reload_match_fields(); DataManager.reload_match_fields();
@@ -51,89 +51,89 @@ public class PitSelectorFragment extends Fragment {
return binding.getRoot(); return binding.getRoot();
} }
load_teams(); // load_teams();
return binding.getRoot(); return binding.getRoot();
} }
public void load_teams(){ // public void load_teams(){
// binding.pitFileIndicator.setVisibility(View.GONE); //// binding.pitFileIndicator.setVisibility(View.GONE);
// binding.pitTeamName.setVisibility(View.GONE); //// binding.pitTeamName.setVisibility(View.GONE);
// binding.pitTeamDescription.setVisibility(View.GONE); //// binding.pitTeamDescription.setVisibility(View.GONE);
////
//// clear_fields();
// //
// clear_fields(); //
// int[] teamNums = new int[event.teams.size()];
//
int[] teamNums = new int[event.teams.size()]; // for(int i = 0 ; i < event.teams.size(); i++){
// teamNums[i] = event.teams.get(i).teamNumber;
for(int i = 0 ; i < event.teams.size(); i++){ // }
teamNums[i] = event.teams.get(i).teamNumber; //
} // Arrays.sort(teamNums);
//
Arrays.sort(teamNums); // TableLayout table = new TableLayout(getContext());
// table.setStretchAllColumns(true);
TableLayout table = new TableLayout(getContext()); // binding.teams.addView(table);
table.setStretchAllColumns(true); //
binding.teams.addView(table); //
// for(int i = 0; i < event.teams.size(); i++){
// frcTeam team = null;
for(int i = 0; i < event.teams.size(); i++){ // for(int a = 0 ; a < event.teams.size(); a++){
frcTeam team = null; // if(event.teams.get(a).teamNumber == teamNums[i]){
for(int a = 0 ; a < event.teams.size(); a++){ // team = event.teams.get(a);
if(event.teams.get(a).teamNumber == teamNums[i]){ // break;
team = event.teams.get(a); // }
break; // }
} // assert team != null;
} //
assert team != null; //// TableRow tr = new TableRow(getContext());
//// TableLayout.LayoutParams rowParams = new TableLayout.LayoutParams(
// TableRow tr = new TableRow(getContext()); //// FrameLayout.LayoutParams.WRAP_CONTENT,
// TableLayout.LayoutParams rowParams = new TableLayout.LayoutParams( //// FrameLayout.LayoutParams.WRAP_CONTENT
// FrameLayout.LayoutParams.WRAP_CONTENT, //// );
// FrameLayout.LayoutParams.WRAP_CONTENT //// rowParams.setMargins(20,20,20,20);
// ); //// tr.setLayoutParams(rowParams);
// rowParams.setMargins(20,20,20,20); //// tr.setPadding(20,20,20,20);
// tr.setLayoutParams(rowParams); //// table.addView(tr);
// tr.setPadding(20,20,20,20); //
// table.addView(tr); // TeamListOption teamRow = new TeamListOption(getContext());
// table.addView(teamRow);
TeamListOption teamRow = new TeamListOption(getContext()); // teamRow.fromTeam(team);
table.addView(teamRow); //
teamRow.fromTeam(team); //
// String filename = evcode + "-" + team.teamNumber + ".pitscoutdata";
//
String filename = evcode + "-" + team.teamNumber + ".pitscoutdata"; // if (FileEditor.fileExist(filename)) {
// final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
if (FileEditor.fileExist(filename)) { //
final boolean[] rescout = {DataManager.rescout_list.contains(filename)}; // teamRow.setColor(DataManager.rescout_list.contains(filename) ? color_rescout : color_found);
//
teamRow.setColor(DataManager.rescout_list.contains(filename) ? color_rescout : color_found); // teamRow.setOnLongClickListener(v -> {
// rescout[0] = !rescout[0];
teamRow.setOnLongClickListener(v -> { // if(rescout[0]){
rescout[0] = !rescout[0]; // DataManager.rescout_list.add(filename);
if(rescout[0]){ // teamRow.setColor(color_rescout);
DataManager.rescout_list.add(filename); // DataManager.save_rescout_list();
teamRow.setColor(color_rescout); // }else{
DataManager.save_rescout_list(); // DataManager.rescout_list.remove(filename);
}else{ // teamRow.setColor(color_found);
DataManager.rescout_list.remove(filename); // DataManager.save_rescout_list();
teamRow.setColor(color_found); // }
DataManager.save_rescout_list(); //
} //
// return true;
// });
return true; // } else {
}); // teamRow.setColor(color_not_found);
} else { // teamRow.setOnLongClickListener(v -> true);
teamRow.setColor(color_not_found); // }
teamRow.setOnLongClickListener(v -> true); //
} //
// frcTeam finalTeam = team;
// teamRow.setOnClickListener(v -> onSelect.onSelect(this, finalTeam));
frcTeam finalTeam = team; // }
teamRow.setOnClickListener(v -> onSelect.onSelect(this, finalTeam)); // }
}
}
} }
@@ -19,34 +19,37 @@ import com.ridgebotics.ridgescout.R;
import com.ridgebotics.ridgescout.types.frcTeam; import com.ridgebotics.ridgescout.types.frcTeam;
// A view that acts as a row specifically to display a team and their icon in a list formmt. // A view that acts as a row specifically to display a team and their icon in a list formmt.
public class TeamListOption extends LinearLayout { public class TeamListOption extends RecyclerHolder<frcTeam> {
public TeamListOption(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public TeamListOption(Context context) {
super(context);
init(context);
}
// public TeamListOption(Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// init(context);
// }
//
// public TeamListOption(Context context) {
// super(context);
// init(context);
// }
//
private TextView teamNumber; private TextView teamNumber;
private TextView teamName; private TextView teamName;
private ImageView teamLogo; private ImageView teamLogo;
private ConstraintLayout box; private ConstraintLayout box;
private View coloredBackground; private View coloredBackground;
//
public TeamListOption(View view) {
super(view);
// LayoutInflater.from(context).inflate(R.layout.view_team_option, this, true);
public void init(Context context) { teamNumber = view.findViewById(R.id.field_option_type);
LayoutInflater.from(context).inflate(R.layout.view_team_option, this, true); teamName = view.findViewById(R.id.field_option_name);
teamLogo = view.findViewById(R.id.team_option_logo);
teamNumber = findViewById(R.id.field_option_type);
teamName = findViewById(R.id.field_option_name);
teamLogo = findViewById(R.id.team_option_logo);
box = findViewById(R.id.team_option_box); box = view.findViewById(R.id.team_option_box);
coloredBackground = findViewById(R.id.team_option_background); coloredBackground = view.findViewById(R.id.team_option_background);
} }
public void setTeamNumber(int num){ public void setTeamNumber(int num){
@@ -59,6 +62,7 @@ public class TeamListOption extends LinearLayout {
public void setTeamLogo(Bitmap bitmap){ public void setTeamLogo(Bitmap bitmap){
teamLogo.setImageBitmap(bitmap); teamLogo.setImageBitmap(bitmap);
showLogo();
} }
public void hideLogo(){ public void hideLogo(){
@@ -68,7 +72,8 @@ public class TeamListOption extends LinearLayout {
teamLogo.setVisibility(View.VISIBLE); teamLogo.setVisibility(View.VISIBLE);
} }
public void fromTeam(frcTeam team){ @Override
public void bind(frcTeam team, int position){
setTeamNumber(team.teamNumber); setTeamNumber(team.teamNumber);
setTeamName(team.teamName); setTeamName(team.teamName);
+4 -17
View File
@@ -17,25 +17,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ScrollView <LinearLayout
android:id="@+id/table"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="50dp"
android:orientation="vertical">
<TableLayout
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.ridgebotics.ridgescout.ui.views.CustomSpinnerView <com.ridgebotics.ridgescout.ui.views.CustomSpinnerView
android:id="@+id/data_type_dropdown" android:id="@+id/data_type_dropdown"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -43,10 +33,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</TableLayout>
</LinearLayout> </LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
+3 -1
View File
@@ -30,11 +30,13 @@
android:layout_height="54dp" android:layout_height="54dp"
android:layout_margin="2dp" android:layout_margin="2dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/ic_robologo" /> tools:srcCompat="@drawable/ic_robologo"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/field_option_name" android:id="@+id/field_option_name"
+4
View File
@@ -1,5 +1,6 @@
[versions] [versions]
agp = "8.11.1" agp = "8.11.1"
asynclayoutinflator = "1.1.0"
junit = "4.13.2" junit = "4.13.2"
junitVersion = "1.1.5" junitVersion = "1.1.5"
espressoCore = "3.5.1" espressoCore = "3.5.1"
@@ -10,11 +11,13 @@ lifecycleLivedataKtx = "2.6.1"
lifecycleViewmodelKtx = "2.6.1" lifecycleViewmodelKtx = "2.6.1"
material3 = "1.3.1" material3 = "1.3.1"
navigationFragment = "2.6.0" navigationFragment = "2.6.0"
navigationFragmentVersion = "2.8.9"
navigationUi = "2.6.0" navigationUi = "2.6.0"
supportAnnotations = "28.0.0" supportAnnotations = "28.0.0"
preference = "1.2.1" preference = "1.2.1"
[libraries] [libraries]
asynclayoutinflator = { module = "androidx.asynclayoutinflator:asynclayoutinflator", version.ref = "asynclayoutinflator" }
junit = { group = "junit", name = "junit", version.ref = "junit" } junit = { group = "junit", name = "junit", version.ref = "junit" }
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
@@ -25,6 +28,7 @@ lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-lived
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" } lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" } material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment", version.ref = "navigationFragment" } navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment", version.ref = "navigationFragment" }
navigation-fragment-v289 = { module = "androidx.navigation:navigation-fragment", version.ref = "navigationFragmentVersion" }
navigation-ui = { group = "androidx.navigation", name = "navigation-ui", version.ref = "navigationUi" } navigation-ui = { group = "androidx.navigation", name = "navigation-ui", version.ref = "navigationUi" }
support-annotations = { group = "com.android.support", name = "support-annotations", version.ref = "supportAnnotations" } support-annotations = { group = "com.android.support", name = "support-annotations", version.ref = "supportAnnotations" }
preference = { group = "androidx.preference", name = "preference", version.ref = "preference" } preference = { group = "androidx.preference", name = "preference", version.ref = "preference" }