Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ScoutingRadar2022/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,43 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_match_record_list, container, false);

// Get the recycler view
RecyclerView recyclerView = view.findViewById(R.id.record_recycler);
// Create the adapter
final MatchRecordRecyclerViewAdapter adapter =
new MatchRecordRecyclerViewAdapter(new MatchRecordRecyclerViewAdapter.RecordDiff());
// Set up the recycler view with the adapter
Context context = view.getContext();
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(adapter);

// Create the ViewModel
MatchViewModel mMatchViewModel = new ViewModelProvider(this).get(MatchViewModel.class);

// Connect the viewModel and thus the database with the adapter and thus the recycler view
mMatchViewModel.getDataList().observe(getViewLifecycleOwner(), adapter::submitList);
// For the Objective Match Record
// Get the recycler view
RecyclerView recyclerView = view.findViewById(R.id.record_recycler);
// Create the adapter
final MatchRecordRecyclerViewAdapter adapter =
new MatchRecordRecyclerViewAdapter(new MatchRecordRecyclerViewAdapter.RecordDiff());
// Set up the recycler view with the adapter
Context context = view.getContext();
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(adapter);

// Create the ViewModel
MatchViewModel mMatchViewModel = new ViewModelProvider(this).get(MatchViewModel.class);

// Connect the viewModel and thus the database with the adapter and thus the recycler view
mMatchViewModel.getDataList().observe(getViewLifecycleOwner(), adapter::submitList);


// For the Pit Match Record
// Get the recycler view
RecyclerView recyclerViewPit = view.findViewById(R.id.pit_record_recycler);
// Create the adapter
final PitRecordRecyclerViewAdapter adapterPit =
new PitRecordRecyclerViewAdapter(new PitRecordRecyclerViewAdapter.RecordDiff());
// Set up the recycler view with the adapter
Context contextPit = view.getContext();
recyclerViewPit.setLayoutManager(new LinearLayoutManager(contextPit));
recyclerViewPit.setAdapter(adapterPit);

// Create the ViewModel
PitTeamViewModel mPitTeamViewModel = new ViewModelProvider(this).get(PitTeamViewModel.class);

// Connect the viewModel and thus the database with the adapter and thus the recycler view
mPitTeamViewModel.getDataList().observe(getViewLifecycleOwner(), adapterPit::submitList);


// Setting up SpeedDialView
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.stormroboticsnj.scoutingradar2022.homefragment;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;

import org.stormroboticsnj.scoutingradar2022.R;
import org.stormroboticsnj.scoutingradar2022.database.pit.PitScoutData;
import org.stormroboticsnj.scoutingradar2022.databinding.FragmentMatchRecordBinding;

/**
* {@link RecyclerView.Adapter} that can display an {@link PitScoutData}.
*/
public class PitRecordRecyclerViewAdapter extends ListAdapter<PitScoutData, PitRecordRecyclerViewAdapter.PitRecordViewHolder> {
protected PitRecordRecyclerViewAdapter(
@NonNull
DiffUtil.ItemCallback<PitScoutData> diffCallback) {
super(diffCallback);
}

@NonNull
@Override
public PitRecordViewHolder onCreateViewHolder(
@NonNull ViewGroup parent, int viewType) {
return new PitRecordViewHolder(
FragmentMatchRecordBinding.inflate(LayoutInflater.from(parent.getContext()), parent,
false));
}

@Override
public void onBindViewHolder(
@NonNull PitRecordViewHolder holder, int position) {
holder.bind(getItem(position));
}


public static class PitRecordViewHolder extends RecyclerView.ViewHolder {
public final TextView mTeamNumView;
PitScoutData mItem;

public PitRecordViewHolder(FragmentMatchRecordBinding binding) {
super(binding.getRoot());
mTeamNumView = binding.recordTextTeamNumber;
}

public void bind(PitScoutData item) {
mItem = item;
mTeamNumView.setText(mTeamNumView.getContext().getResources().getString(R.string.record_text_team, item.getTeamNum()));
}

@Override
@NonNull
public String toString() {
return super.toString() + " '" + mTeamNumView.getText() + "'";
}
}

public static class RecordDiff extends DiffUtil.ItemCallback<PitScoutData> {
@Override
public boolean areItemsTheSame(
@NonNull PitScoutData oldItem, @NonNull PitScoutData newItem) {
return oldItem == newItem;
}

@Override
public boolean areContentsTheSame(
@NonNull PitScoutData oldItem, @NonNull PitScoutData newItem) {
return (oldItem.getTeamNum() == newItem.getTeamNum());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.stormroboticsnj.scoutingradar2022.homefragment;

import android.app.Application;

import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;


import org.stormroboticsnj.scoutingradar2022.database.pit.PitRepository;
import org.stormroboticsnj.scoutingradar2022.database.pit.PitScoutData;

import java.util.List;

public class PitTeamViewModel extends AndroidViewModel {

private final PitRepository mRepository;
private final LiveData<List<PitScoutData>> mDataList;

public PitTeamViewModel (Application app) {
super(app);
mRepository = new PitRepository(app);
mDataList = mRepository.getDataList();
}

public LiveData<List<PitScoutData>> getDataList() {
return mDataList;
}

public void insert(PitScoutData team) {
mRepository.insert(team);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,31 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/record_recycler"
app:layout_constraintTop_toBottomOf="@id/record_text_title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="@layout/fragment_match_record"
android:layout_height="177dp"
android:layout_width="379dp"
android:padding="16dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/record_text_title"
app:layout_constraintVertical_bias="0.034"
tools:listitem="@layout/fragment_match_record" />

<TextView
android:id="@+id/pit_record_text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
app:layout_constraintTop_toBottomOf="@id/record_recycler"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
android:textAlignment="center"
android:textAppearance="?textAppearanceOverline"
android:textSize="16sp"
android:text="@string/pit_recycler_title" />

<com.leinardi.android.speeddial.SpeedDialView
android:layout_width="wrap_content"
Expand All @@ -72,5 +87,19 @@
app:layout_constraintBottom_toBottomOf="parent"
app:sdMainFabClosedSrc="@drawable/ic_baseline_add_24" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pit_record_recycler"
android:layout_height="177dp"
android:layout_width="379dp"
android:padding="16dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pit_record_text_title"
app:layout_constraintVertical_bias="0.018"
tools:listitem="@layout/fragment_match_record" />


</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions ScoutingRadar2022/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="settings">Settings</string>

<string name="recycler_title">Previously Scouted Matches (Objective)</string>
<string name="pit_recycler_title">Previously Scouted Teams (Pit)</string>
<string name="team_number">Team Number</string>
<string name="match_number">Match Number</string>
<string name="user_initial">User Initials</string>
Expand Down